<?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>Grummfy&#039;s project &#187; PHP</title>
	<atom:link href="http://grummfy.be/blog/cat/php/feed" rel="self" type="application/rss+xml" />
	<link>http://grummfy.be/blog</link>
	<description>Mes projets, mes rêves, mes envies, ...</description>
	<lastBuildDate>Mon, 02 Jan 2012 00:03:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Création de nouveau formulaire facilement avec Zend Form Maker</title>
		<link>http://grummfy.be/blog/381#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/381#comments</comments>
		<pubDate>Sat, 29 Oct 2011 22:29:52 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=381</guid>
		<description><![CDATA[La création de formulaire avec zend framework peut être facilitée grâce à un petit développement : Zend Form Maker. Projet disponible sur github. À la base créer pour des besoins scolaires, sarlak a eu la bonne idée de rendre le dev open source sous licence GPL 3.0. Le but du logiciel est de permettre via [...]]]></description>
			<content:encoded><![CDATA[<p>La création de formulaire avec zend framework peut être facilitée grâce à un petit développement : Zend Form Maker. Projet disponible sur github. À la base créer pour des besoins scolaires, sarlak a eu la bonne idée de rendre le dev open source sous licence GPL 3.0.</p>
<p>Le but du logiciel est de permettre via une interface très simple d&#8217;accès, de créer des formulaires et ensuite de forger une classe PHP, basé sur zend framework afin d&#8217;obtenir un formulaire tout frais moulu. Ultra pratique, et ultra simple, et surtout cela fait gagner un temps de dingue!</p>
<p>Pour l&#8217;installer, il vous faut de quoi faire fonctionner zend framework (celui-ci doit être installé). Sous Unix cela donnera ceci :<br />
<code><br />
git clone https://github.com/sarlak/Zend-Form-Maker.git<br />
ln -s pathToYourZFLibrary<br />
chmod 0777 Zend-Form-Maker/public/resources/xml<br />
chmod 0777 Zend-Form-Maker/public/resources/form_made<br />
</code></p>
<p>Bien entendu, à peu de choses près ceci est adaptable sous MS-Windows</p>
<p>Pour créer votre premier formulaire, il vous suffit de vous rendre sur l&#8217;URL adéquate, aller sur &laquo;&nbsp;form list&nbsp;&raquo; et &laquo;&nbsp;Bazinga!&nbsp;&raquo;. Une <a href="http://demo.zfm.matthieudiblasio.ch/" title="démo" target="_blank">démo</a> existe en ligne!</p>
<p>Une petite capture d&#8217;écran :<br />
<a href="http://grummfy.be/blog/381/capture-zend-form-maker-v1-0-mozilla-firefox" rel="attachment wp-att-383"><img src="http://grummfy.be/blog/wp/wp-content/uploads/2011/10/Capture-Zend-Form-Maker-v1.0-Mozilla-Firefox-300x185.png" alt="" title="Capture-Zend Form Maker v1.0" width="300" height="185" class="aligncenter size-medium wp-image-383" /></a></p>
<p>À noter que j&#8217;ai corrigé un ou deux petits trucs qui me dérangeaient, il y a un bout de temps.</p>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;linkname=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F381&amp;title=Cr%C3%A9ation%20de%20nouveau%20formulaire%20facilement%20avec%20Zend%20Form%20Maker" id="wpa2a_2"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/381/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZF : ACL et ressources multiple</title>
		<link>http://grummfy.be/blog/360#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/360#comments</comments>
		<pubDate>Wed, 13 Oct 2010 21:19:21 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=360</guid>
		<description><![CDATA[Utiliser les ACL dans Zend Framework en ajoutant le support de ressource multiple via '*'.]]></description>
			<content:encoded><![CDATA[<p>Lorsque l&#8217;on utilise des ACL dans Zend Framework, une chose assez embêtante est de devoir tout mettre en place<sup class='footnote'><a href='#fn-360-1' id='fnref-360-1'>1</a></sup>. Pour ma part, j&#8217;ai par facilité voulu ajouté le support de ressource multiple.</p>
<p>Avant de commencer, il convient de contextualisé les choses, les ACL de ZF pouvant être utilisé de bien des manière.</p>
<p>Dans le cas qui nous intéresse, j&#8217;ai simplement défini ceci :</p>
<ul>
<li>les ressources<sup class='footnote'><a href='#fn-360-2' id='fnref-360-2'>2</a></sup> = module.controller</li>
<li>les privilèges<sup class='footnote'><a href='#fn-360-3' id='fnref-360-3'>3</a></sup> = action</li>
</ul>
<p>Ce que je voulait c&#8217;est pouvoir définir une ressource pour tous les contrôleurs. La syntaxe évidente qu&#8217;il m&#8217;est venu est la suivante : module.*</p>
<p>Dans ma classe qui étend Zend_ACL j&#8217;ai simplement fait ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> isAllowed<span style="color: #009900;">&#40;</span><span style="color: #000088;">$role</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resource</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$privilege</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$resource</span><span style="color: #009900;">&#41;</span>
    		<span style="color: #b1b100;">return</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">isAllowed</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$role</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resource</span><span style="color: #339933;">,</span> <span style="color: #000088;">$privilege</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	<span style="color: #000088;">$resources</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getResourcesPossibility<span style="color: #009900;">&#40;</span><span style="color: #000088;">$resource</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;">$resources</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$resource</span><span style="color: #009900;">&#41;</span>
    	<span style="color: #009900;">&#123;</span>
    		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>has<span style="color: #009900;">&#40;</span><span style="color: #000088;">$resource</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">isAllowed</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$role</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resource</span><span style="color: #339933;">,</span> <span style="color: #000088;">$privilege</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    		<span style="color: #009900;">&#123;</span>
    			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    		<span style="color: #009900;">&#125;</span>
    	<span style="color: #009900;">&#125;</span>
    	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getResourcesPossibility<span style="color: #009900;">&#40;</span><span style="color: #000088;">$resource</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;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resource</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: #009900; font-weight: bold;">null</span> <span style="color: #339933;">!==</span> <span style="color: #000088;">$resource</span><span style="color: #009900;">&#41;</span>
    	<span style="color: #009900;">&#123;</span>
    		<span style="color: #000088;">$resources</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resource</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    		<span style="color: #000088;">$cptRessources</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resources</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;">$cptRessources</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
    		<span style="color: #009900;">&#123;</span>
    			<span style="color: #000088;">$resources</span><span style="color: #009900;">&#91;</span> <span style="color: #000088;">$cptRessources</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'*'</span><span style="color: #339933;">;</span>
    		<span style="color: #009900;">&#125;</span>
    		<span style="color: #000088;">$ret</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resources</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #009900;">&#125;</span>
    	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$ret</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ceci peut bien entendu être enrichi mais permet au moins de profiter de l&#8217;utilisation des ACL dans le menu et sur des aides de vue qui serait éventuellement définie comme expliqué dans la plupart des tutoriaux.</p>
<p>Pour en savoir plus sur les ACL et Zend Framework, je vous renvoi a un très bon <a href="http://julien-pauli.developpez.com/tutoriels/zend-framework/atelier/aclmvc/" target="_blank">article</a>.</p>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-360-1'>surtout si on utilise l&#8217;aide de vue pour généré un menu (Zend_navigation) <span class='footnotereverse'><a href='#fnref-360-1'>&#8617;</a></span></li>
<li id='fn-360-2'>resource <span class='footnotereverse'><a href='#fnref-360-2'>&#8617;</a></span></li>
<li id='fn-360-3'>privilege <span class='footnotereverse'><a href='#fnref-360-3'>&#8617;</a></span></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/360/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Espace de nom PHP et chargement automatique</title>
		<link>http://grummfy.be/blog/285#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/285#comments</comments>
		<pubDate>Mon, 07 Jun 2010 08:42:44 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=285</guid>
		<description><![CDATA[PHP 5.3 ajoute une notion intéressante : les espaces de nom. Voyons voir comment créer un chargeur automatique (ou autoloader) comprenant ceux-ci.]]></description>
			<content:encoded><![CDATA[<p><a href="./zend-framework#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">PHP</a> 5.3 ajoute une notion intéressante : les espaces de nom (ou namespace en anglais). Les espaces de nom permettent de séparer différents &#8230; &laquo;&nbsp;<em>espace</em>&laquo;&nbsp;, permettant ainsi d&#8217;avoir deux classe portant le même nom. Idéal pour l&#8217;utilisation de framework mais aussi de &laquo;&nbsp;l&#8217;isolation&nbsp;&raquo; de certains composants. Voyons voir comment créer un chargeur automatique (ou autoloader) comprenant les espaces de nom.</p>
<p>Si vous êtes sous Ms Windows, aucun problème un simple <em>spl_autoload_register();</em> suffit. Malheureusement, sous *nix un <a href="http://bugs.php.net/bug.php?id=51991" target="_blank">bug existe</a> il faudra donc implémenté une solution maison.</p>
<h2>Le code</h2>
<p>Ce code provient du &laquo;&nbsp;<a href="http://groups.google.com/group/php-standards/web/psr-0-final-proposal" class="broken_link">PHP  Standards Working Group</a>&nbsp;&raquo; :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> autoload<span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ltrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$fileName</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$namespace</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lastNsPos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strripos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$namespace</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lastNsPos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lastNsPos</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: #000088;">$fileName</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\\'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">,</span> <span style="color: #000088;">$namespace</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$fileName</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">,</span> <span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.php'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">require</span> <span style="color: #000088;">$fileName</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</p>
<p>Pour l&#8217;utiliser, il faut définir deux choses :</p>
<ol>
<li>Ne pas oublier de modifier l&#8217;include path si nécessaire.</li>
<li>Ajouter cette fonction au chargeur de classes présent.</li>
</ol>
<h2>L&#8217;exemple</h2>
<p>Voici un exemple un peu plus complet.<br />
index.php</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;">set_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">get_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> PATH_SEPARATOR <span style="color: #339933;">.</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/lib/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//on ajoute le dossier lib dans l'include path</span>
<span style="color: #990000;">spl_autoload_register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//sur windows ceci devrait suffire .</span>
<span style="color: #666666; font-style: italic;">//le code pour les autres</span>
<span style="color: #666666; font-style: italic;">//----------------------------------------------------------</span>
<span style="color: #000000; font-weight: bold;">function</span> autoload<span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ltrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$fileName</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$namespace</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lastNsPos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strripos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$namespace</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lastNsPos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$className</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lastNsPos</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: #000088;">$fileName</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\\'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">,</span> <span style="color: #000088;">$namespace</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$fileName</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">,</span> <span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.php'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">require</span> <span style="color: #000088;">$fileName</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">spl_autoload_register</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'autoload'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//----------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;">//fin du code de fix</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> grummfy\test\Test<span style="color: #339933;">;</span>
Test<span style="color: #339933;">::</span><span style="color: #004000;">sayHello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
\grummfy\std\Test<span style="color: #339933;">::</span><span style="color: #004000;">sayHello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>./lib/grummfy/test/Test.php</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;">namespace</span> grummfy\test<span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//pour rappel ceci doit-être la première instruction php (et on ne doit pas avoir de HTML avant)</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Je suis inclus ('</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">__FILE__</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">')!'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> Test
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Bonjour depuis '</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">__CLASS__</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>./lib/grummfy/std/Test.php</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;">namespace</span> grummfy\std<span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Je suis inclus ('</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">__FILE__</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">')!'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> Test
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Bonjour depuis '</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">__CLASS__</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>Le résultat devrait être :<br />
<code><br />
Je suis inclus (/.../lib/grummfy/test/Test.php)!<br />
Bonjour depuis grummfy\test\Test<br />
Je suis inclus (/.../lib/grummfy/std/Test.php)!<br />
Bonjour depuis grummfy\std\Test<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/285/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wampserver : quick switch xdebug menu</title>
		<link>http://grummfy.be/blog/250#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/250#comments</comments>
		<pubDate>Wed, 24 Mar 2010 22:22:42 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[deboguage]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[jouons]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[XDebug]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=250</guid>
		<description><![CDATA[Activer et désactiver XDebug sur Wampserver à souhait! Ceci via un menu supplémentaire.]]></description>
			<content:encoded><![CDATA[<p>Pour une fois, un article sous Ms Windows. Stage oblige, je passe du temps sous celui-ci (XP <img src='http://grummfy.be/blog/wp/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  ). Afin d&#8217;optimiser son travail, il y a parfois des petites choses bien pratiques, telles que ce que je vais vous présenter.</p>
<p>XDebug est un outil merveilleux, parfois capricieux, certes, mais très utile. Il permet, notamment<sup class='footnote'><a href='#fn-250-1' id='fnref-250-1'>1</a></sup> :</p>
<ul>
<li>Affichage de tracé d&#8217;erreur</li>
<li>Meilleures lectures des exceptions</li>
<li>Débogage pas-à-pas</li>
<li>Profiling d&#8217;application</li>
<li>&#8230;</li>
</ul>
<p>Bref, des choses essentielles en développement. Et, contrairement à ce que certains IDE<sup class='footnote'><a href='#fn-250-2' id='fnref-250-2'>2</a></sup> font, il permet surtout de le faire sur un serveur &laquo;&nbsp;réel&nbsp;&raquo;, donc avec une utilisation &laquo;&nbsp;réel&nbsp;&raquo;.</p>
<p>Le but de ce billet n&#8217;est pas de présenter XDebug, d&#8217;autres le font mieux que moi <sup class='footnote'><a href='#fn-250-3' id='fnref-250-3'>3</a></sup>, mais bien de vous présenter un petit script vous permettant d&#8217;activer et désactiver XDebug sur wampserver.</p>
<h2>Installation</h2>
<ol>
<li>Téléchargez le fichier <sup class='footnote'><a href='#fn-250-4' id='fnref-250-4'>4</a></sup> et décompressez-le.</li>
<li>Suivez les instructions d&#8217;installation décrite dans le fichier installe. Il y a seulement 1 fichier à modifier + 1 fichier par version de PHP installée.</li>
<li>Relancer wampserver et tester!</li>
</ol>
<p>Si vous avez des questions, n&#8217;hésitez pas.</p>
<h2>Plus d&#8217;informations</h2>
<ul>
<li><a href="http://blog.pascal-martin.fr/post/xdebug-installation-premiers-pas" target="_blank">Xdebug : Installation et premier pas</a></li>
<li><a href="http://blog.wampserver.com/index.php/2009/08/28/debugger-avec-wampserver-xdebug-et-pdt/" target="_self" class="broken_link">Débugger avec WampServer, Xdebug et PDT</a></li>
<li><a href="http://evoilliot.u7n.org/2010/02/installer-xdebug-avec-xampp/" target="_blank" class="broken_link">Installer Xdebug avec XAMPP</a></li>
<li><a href="http://www.wampserver.com" target="_blank">Wampserver</a></li>
<li><a href="http://xdebug.com/" target="_blank">XDebug</a></li>
<li>Pièce jointe : <a href="http://grummfy.be/blog/250/xdebug-tar">XDebug quick switch menu for wampserver</a></li>
</ul>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-250-1'>On parle de serveur web avec PHP &#8230; <span class='footnotereverse'><a href='#fnref-250-1'>&#8617;</a></span></li>
<li id='fn-250-2'>Par exemple, Zend Studio permet un débogage pas à pas mais en interne donc réduit &#8230;  <span class='footnotereverse'><a href='#fnref-250-2'>&#8617;</a></span></li>
<li id='fn-250-3'>cf. plus d&#8217;informations <span class='footnotereverse'><a href='#fnref-250-3'>&#8617;</a></span></li>
<li id='fn-250-4'><a href="http://grummfy.be/blog/250/xdebug-tar">XDebug quick switch menu for wampserver</a> <span class='footnotereverse'><a href='#fnref-250-4'>&#8617;</a></span></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/250/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Activation, désactivation du wifi sur un D-Link DSL-2640B via PHP</title>
		<link>http://grummfy.be/blog/233#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/233#comments</comments>
		<pubDate>Wed, 17 Mar 2010 23:06:52 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Logiciel]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Réflexion du jour]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[réseaux]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=233</guid>
		<description><![CDATA[Un script PHP en ligne de commande pour activer // désactiver le wifi sur un modem D-Link DSL-2640B. Cela permet d&#8217;illustrer un peu l&#8217;intérêt de faire du scripting &#8230; Je ne ferais pas de commentaires, mais n&#8217;hésitez pas à poser des questions &#8230; #!/usr/bin/php &#60;?php &#160; //Variable definition // //router $login = 'admin'; $password = [...]]]></description>
			<content:encoded><![CDATA[<p>Un script PHP en ligne de commande pour activer // désactiver le wifi sur un modem D-Link DSL-2640B. Cela permet d&#8217;illustrer un peu l&#8217;intérêt de faire du scripting &#8230;</p>
<p>Je ne ferais pas de commentaires, mais n&#8217;hésitez pas à poser des questions &#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">#!/usr/bin/php
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Variable definition</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//router</span>
<span style="color: #000088;">$login</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'admin'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'admin'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'192.168.1.1'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//wifi</span>
<span style="color: #000088;">$wifi</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;">// /!\ don't touch this /!\</span>
	<span style="color: #0000ff;">'wlSsidIdx'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlEnbl'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlCountry'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'GB'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlBasicRate'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//ssid name</span>
	<span style="color: #0000ff;">'wlSsid'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'monSuperRéseauxWifi'</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">//0 = visible, 1 = hide</span>
	<span style="color: #0000ff;">'wlHide'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">//number of chanel or 0 for auto selection</span>
	<span style="color: #0000ff;">'wlChannel'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">//Transmission Speed</span>
	<span style="color: #0000ff;">'wlRate'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">//wifi mode 0=802.11b only, 1=Mixed 802.11g and 802.11b, 4=802.11g only</span>
	<span style="color: #0000ff;">'wlgMode'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span>
&nbsp;
	<span style="color: #0000ff;">'wlWpaGTKRekey'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">750</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlWpa'</span>			<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'aes'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlAuthMode'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'psk2'</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">//authentification mode : 0 = none, 1 = wep, 2 = auto (wpa or wpa2), 3 = wpa2 only, 4 = wpa only</span>
	<span style="color: #0000ff;">'wlAuth'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlWpaPsk'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'masuperclefdelamortquitue'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlWep'</span>		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'disabled'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'wlPreauth'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/////////////////////</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> cli
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">const</span> LINE_BREAK <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">const</span> LINE_NO_BREAK <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">const</span> LINE_RETURN <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">const</span> LINE_NOTHING <span style="color: #339933;">=</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_TEMP</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">250000</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//1/4 of seconds</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_MULTIPLICATOR</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//1/4 -&gt; 4</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_LENGTH</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _write_empty_space<span style="color: #009900;">&#40;</span><span style="color: #000088;">$lng</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lng</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_LENGTH<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$lng</span><span style="color: #339933;">++;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _echo<span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$break</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$break</span> <span style="color: #339933;">==</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NO_BREAK</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_write_empty_space<span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</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: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _sleep<span style="color: #009900;">&#40;</span><span style="color: #000088;">$second</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$second</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$second</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_MULTIPLICATOR<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>
		<span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$second</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">usleep</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_TEMP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NOTHING</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: #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;">$j</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_RETURN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_write_empty_space<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_RETURN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Please wait'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NOTHING</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: #009900;">&#125;</span>
				<span style="color: #000088;">$j</span><span style="color: #339933;">++;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_RETURN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> wifi <span style="color: #000000; font-weight: bold;">extends</span> cli
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_ch</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_baseUrl</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ip</span><span style="color: #339933;">,</span> <span style="color: #000088;">$login</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #339933;">,</span> <span style="color: #000088;">$activation</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_baseUrl <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ip</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_auth<span style="color: #009900;">&#40;</span><span style="color: #000088;">$login</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$activation</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$activation</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$activation</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_activation<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_disactivation<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __destruct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _activation<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Activation ...'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NO_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$wifi</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wlBasicRate'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wlgMode'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'wifi2'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'default'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_doQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_baseUrl <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wirelesssetting.wl?'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">http_build_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_sleep<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _disactivation<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Disactivation ...'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NO_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$wifiDown</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'wlEnbl'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'wlSsidIdx'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$wifi</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wlSsidIdx'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'wlCountry'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$wifi</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wlCountry'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_doQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_baseUrl <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wirelesssetting.wl?'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">http_build_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifiDown</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_sleep<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _doQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_POST<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: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #339933;">,</span> CURLOPT_HTTPGET<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_ch<span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error Curl : '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">curl_error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DONE'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _auth<span style="color: #009900;">&#40;</span><span style="color: #000088;">$login</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Authentification ...'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">LINE_NO_BREAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'username'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$login</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'password'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$password</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_doQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_baseUrl <span style="color: #339933;">.</span> <span style="color: #0000ff;">'index.html'</span><span style="color: #339933;">,</span> <span style="color: #990000;">http_build_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&amp;'</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: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$argc</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' synthaxe : scriptname.php 1 for activation or 0 for desactivation '</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">new</span> wifi<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wifi</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ip</span><span style="color: #339933;">,</span> <span style="color: #000088;">$login</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #339933;">,</span> <span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>Certes, le script ne gère pas tout, mais le but était de jouer avec la ligne de commande tout en n’allant pas dans les extensions exotiques de gestion de celle-ci &#8230;.</p>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;linkname=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F233&amp;title=Activation%2C%20d%C3%A9sactivation%20du%20wifi%20sur%20un%20D-Link%20DSL-2640B%20via%20PHP" id="wpa2a_4"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/233/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tri de listing sql via des liens dans Zend Framework</title>
		<link>http://grummfy.be/blog/222#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/222#comments</comments>
		<pubDate>Sun, 10 Jan 2010 02:23:44 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=222</guid>
		<description><![CDATA[Dans la plupart des cas lorsque l'on affiche un listing provenant d'une requête sql on aimerait pouvoir offrir le tri à l'utilisateur. Dans l'article qui suit, je vous propose de découvrir une manière de le faire assez facilement.]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Dans la plupart des cas lorsque l&#8217;on affiche un listing provenant d&#8217;une requête sql on aimerait pouvoir offrir le tri à l&#8217;utilisateur. Dans l&#8217;article qui suit, je vous propose de découvrir une manière de le faire assez facilement.</p>
<p><span id="more-222"></span></p>
<p style="text-align: justify;">Comme exemple nous prendrons le cas d&#8217;une liste via l&#8217;appelle du contrôleur membres et de l&#8217;action liste.</p>
<p style="text-align: justify;">Dans le fichier <em>MembresController.php</em> nous aurons donc une méthode <em>listeAction()</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> listeAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$membres</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Default_Model_DbTable_Membres<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entries</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$membres</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Et dans la vue <em>membres/liste.phtml</em> nous aurons :</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: #000088;">$rowCount</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entries</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;">$rowCount</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;table&gt;
	&lt;tr&gt;
		&lt;th&gt;Nom&lt;/th&gt;
		&lt;th&gt;Adresse&lt;/th&gt;
		&lt;th&gt;Code postal&lt;/th&gt;
		&lt;th&gt;Ville&lt;/th&gt;
		&lt;th&gt;Email&lt;/th&gt;
	&lt;/tr&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entrie</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;tr&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addrese</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">postCode</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cityName</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
	&lt;/tr&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/table&gt;'</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;">'&lt;div&gt;Aucun membre n\'est enregistré!&lt;br /&gt;;)&lt;br /&gt;&lt;/div&gt;'</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>Jusque là, normalement, rien de bien complexe pour celui qui connait ZF.</p>
<p style="text-align: justify;">Ajoutons deux fichiers (cf <a rel="attachment wp-att-223" href="http://grummfy.be/blog/222/zf-tuto-order-by">pièce jointe</a>) dans le dossier librairy/Gru.</p>
<p style="text-align: justify;">
Nous devons ensuite les charger de manière automatique. Pour ce faire, dans le bootstrap.php (dont un extrait possible est présent ci-dessous) ajoutons les informations nécessaires au chargement des fichiers :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initAutoload<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// nos deux lignes ajoutées</span>
		<span style="color: #000088;">$autoloader</span> <span style="color: #339933;">=</span> Zend_Loader_Autoloader<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$autoloader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">registerNamespace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Gru'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// fin de l'ajout</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Exemple de ce qu'il pourrait y avoir en plus!</span>
		<span style="color: #000088;">$autoloader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application_Module_Autoloader<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'namespace'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Default'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'basePath'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$autoloader</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$view</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_View<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$viewRenderer</span> <span style="color: #339933;">=</span> Zend_Controller_Action_HelperBroker<span style="color: #339933;">::</span><span style="color: #004000;">getStaticHelper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ViewRenderer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$viewRenderer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setView</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$view</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//début ajout</span>
		<span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addHelperPath</span><span style="color: #009900;">&#40;</span>APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../library/Gru/View/Helper/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Gru_View_Helper_'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// fin de l'ajout</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$view</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Maintenant, modifions notre application pour ajouter le tri. Reprenons notre contrôleur et modifions la méthode <em>listeAction().</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> listeAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Gestion du tri</span>
	<span style="color: #000088;">$order</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Gru_OrderBy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'membre'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Ajout des clefs de tri</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Nom'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Adresse'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'postCode'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Code postal'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cityName'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Ville'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Courriel'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// injection des requêtes get</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insertRequestParams</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'order'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'by'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderKeys</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getKeys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000088;">$membres</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Default_Model_DbTable_Membres<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//ne pas oubleir d'ajouter les champs trier au moment de la requête sql</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entries</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$membres</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSqlKeys</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: #009900;">&#125;</span></pre></div></div>

<p>Et pour finir notre vue :</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: #000088;">$rowCount</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entries</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;">$rowCount</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;table&gt;
	&lt;tr&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderBy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">th</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderKeys</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">baseUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/themes/images/'</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>
	&lt;/tr&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entrie</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;tr&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addrese</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">postCode</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cityName</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
		&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">escape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;
	&lt;/tr&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/table&gt;'</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;">'&lt;div&gt;Aucun membre n\'est enregistré!&lt;br /&gt;;)&lt;br /&gt;&lt;/div&gt;'</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>Dans l&#8217;exemple, nous afficherons des icônes suivant le sens du tri, icônes se trouvant dans le répertoire spécifié. Un clic sur les titres permet de trier suivant la colonne cliquée. A noter qu&#8217;ici Adresse ne sera pas triable du au fait de la non précision de l&#8217;ordre.</p>
<p style="text-align: justify;">Il y aurait moyen d&#8217;améliorer le script :</p>
<ul>
<li>utilisations de décorateurs</li>
<li>utilisation de traduction</li>
<li>Gru_OrderBy devrait être un plugins</li>
<li>&#8230;</li>
</ul>
<p style="text-align: justify;">En attendant, j&#8217;espère que ce bout de code vous facilitera la vie!</p>
<p style="text-align: justify;">Des remarques, des questions? Postez un commentaire!</p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/222/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Utilisation de FlashMessenger via un view helper dans Zend Framework</title>
		<link>http://grummfy.be/blog/191#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/191#comments</comments>
		<pubDate>Sun, 27 Dec 2009 18:21:56 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=191</guid>
		<description><![CDATA[FlashMessanger est à la base un action helper, donc confiné au contrôleur. Cependant, c'est tellement pratique qu'il est dommage de ne pas pouvoir l'utiliser a travers les vue (view)... Je vous propose donc de l'utiliser via un view helper!]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a title="Manuel Zend Framework sur FlashMessenger" href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.flashmessenger">FlashMessanger</a> est à la base un action helper, donc confiné au contrôleur. Celui-ci permet de passer un message d&#8217;une page à l&#8217;autre via le mécanisme des sessions . Après un formulaire on doit souvent ajouter un message de confirmation, on peux par exemple utilisé le FlashMessenger pour le faire et ainsi au ré-affichage suivant  afficher ce message!  C&#8217;est tellement pratique qu&#8217;il est dommage de ne pas pouvoir l&#8217;utiliser a travers les vue (view) de manière automatique&#8230;</p>
<p>Je vous propose donc de l&#8217;utiliser via un view helper!</p>
<p><span id="more-191"></span></p>
<h2>L&#8217;aide de vue</h2>
<p style="text-align: justify;">Voici l&#8217;aide de vue (view helper) FlashMessenger (du même nom que l&#8217;action helper). Il est à placer dans application/views/helpers/FlashMessenger.php</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: #009933; font-style: italic;">/**
 * @see Zend_Controller_Action_Helper_FlashMessenger
 */</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Controller/Action/Helper/FlashMessenger.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * @author grummfy
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Zend_View_Helper_FlashMessenger <span style="color: #000000; font-weight: bold;">extends</span> Zend_View_Helper_Abstract implements IteratorAggregate<span style="color: #339933;">,</span> Countable
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_fm</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Controller_Action_Helper_FlashMessenger<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> flashMessenger<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cur</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$cur</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Return currents FlashMessegenr object
	 * @return Zend_Controller_Action_Helper_FlashMessenger
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getFlasMessenger<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Return previous emmited messages
	 * @return array
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getMessages<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm<span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessages</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Renvoi le nombre de messages passé
	 * @return int
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> hasMessages<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getIterator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm<span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fm<span style="color: #339933;">-&gt;</span><span style="color: #004000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

</p>
<h2>Utilisation</h2>
<p style="text-align: justify;">
Pour l&#8217;utiliser rien de plus simple, par exemple dans le layout :</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: #666666; font-style: italic;">// flashmessage</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashMessenger</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hasMessages</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>
	&lt;div id=&quot;flashMessengers&quot;&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span>
			<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashMessenger</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div class=&quot;flashMessenger&quot;&gt;'</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">else</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;/div&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// fin flashmessage</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Ceci peut très bien être utilisé dans votre vue (view) avec exactement le même code!</p>
<p style="text-align: justify;">Pour envoyer le message il vous suffit de simplement faire, dans votre contrôleur :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_helper<span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashMessenger</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Mise à jour du truc effectuées avec succès!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</p>
<p></p>
<p style="text-align: justify;">
Et c&#8217;est tout!</p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/191/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Créer et ajouter un validateur de session dans Zend Framework</title>
		<link>http://grummfy.be/blog/186#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/186#comments</comments>
		<pubDate>Sat, 19 Dec 2009 16:30:17 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=186</guid>
		<description><![CDATA[Zend Framework possède divers mécanismes de sécurisation, parmi ceux-ci l&#8217;on trouvent les validateurs. Ces validateurs vérifie que la ou les données à validées sont valide et par là même sécurise celle-ci. Dans notre cas nous allons nous intéresser aux sessions et plus particulièrement à la validation de celle-ci au moment de sont démarrage, ceci afin [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: justify;">
<p>Zend Framework possède divers mécanismes de sécurisation, parmi ceux-ci l&#8217;on trouvent les validateurs. Ces validateurs vérifie que la ou les données à validées sont valide et par là même sécurise celle-ci.</p>
<p>Dans notre cas nous allons nous intéresser aux sessions et plus particulièrement à la validation de celle-ci au moment de sont démarrage, ceci afin de, par exemple, <span style="text-decoration: line-through;">empêcher le</span> diminuer les possibilités de vol de celle-ci. Nous allons créer un validateur d&#8217;ip &#8230; (oui je sais y a moyen de passer outre, si on derrière un proxy gnagnagna &#8230;. mais ici c&#8217;est un exemple!).</p>
<p><span id="more-186"></span></p>
<h2>Rermarque</h2>
<p>Nous utiliserons Zend Framework en version 1.9.<br />
De plus, nous allons créer notre librairie qui se nomera &laquo;&nbsp;Biblio&nbsp;&raquo;. Donc, il faudra penser à créer dasn votre répertoire library le dossier Biblio!</p>
<h2>Les sessions</h2>
<p>Tout d&#8217;abord mettons en place le mécanisme de session. Dans le Bootstrap nous ajoutons la méthode suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initSession<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	Zend_Session<span style="color: #339933;">::</span><span style="color: #004000;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Le validateur</h2>
<p>Passons à la création proporement dite, créons le fichier /library/Biblio/Session/Validator/Ip.php, dont le contenu sera</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">setValidData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>? <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</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;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Validate() - this method will determine if the ip matches the
	 * ip we stored when we initialized this variable.
	 *
	 * @return bool
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> validate<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: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getValidData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>?<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</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;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># EOF</span></pre></div></div>

<p>Ensuite, il nous faut ajouter ce validateur à la session. Donc, on réédite le Bootstrap et on modifie la méthode _initSession() :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initSession<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Biblio/Session/Validator/Ip.php'</span><span style="color: #339933;">;</span>
	Zend_Session<span style="color: #339933;">::</span><span style="color: #004000;">registerValidator</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Biblio_Session_Validator_Ip<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	Zend_Session<span style="color: #339933;">::</span><span style="color: #004000;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>conclusion</h2>
<p>Encore une fois Zend nous montre sa puissance et sa facilité d&#8217;ajout de fonctionnalité. A noter qu&#8217;il existe déjà un validateur pour els session qui contrôle l&#8217;user agent (Zend_Session_Validator_HttpUserAgent()).<br />
N&#8217;hésitez pas a en ajouter!</p>
</div>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;linkname=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F186&amp;title=Cr%C3%A9er%20et%20ajouter%20un%20validateur%20de%20session%20dans%20Zend%20Framework" id="wpa2a_6"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/186/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP : fonction callback et méthode</title>
		<link>http://grummfy.be/blog/72#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/72#comments</comments>
		<pubDate>Mon, 20 Aug 2007 01:15:00 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[jouons]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[trucs et astuces]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=72</guid>
		<description><![CDATA[PHP permet bien des choses, notamment l&#8217;utilisation de fonction de callback. Les fonction de callback sont des fonctions qui seront appeler durant l&#8217;exécution d&#8217;une autre fonction, et ce de manière automatique. C&#8217;est bien souvent le cas lors d&#8217;expression régulière ou encore lors d&#8217;une session php passant par ses propres fonctions (via session_set_save_handler() )! Les fonctions [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/index.php?tag/PHP#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">PHP</a> permet bien des choses, notamment l&#8217;utilisation de fonction de callback. Les fonction de callback sont des fonctions qui seront appeler durant l&#8217;exécution d&#8217;une autre fonction, et ce de manière automatique.</p>
<p>C&#8217;est bien souvent le cas lors d&#8217;expression régulière ou encore lors d&#8217;une session php passant par ses propres fonctions (via session_set_save_handler() )!</p>
<p>Les fonctions de callback peuvent être rpésente sous différentes forme&nbsp;:</p>
<ul>
<li>Fonction de PHP</li>
<li>Fonction que vous avez définie</li>
<li>Méthode static</li>
<li>Méthode non-static</li>
</ul>
<p>Dans le cas de fonctions, il suffit de mettre le nom de la fonction entre guillemet. </p>
<p></p>
<p></p>
<p>Mais dans le cas de méthode, il vous faut utiliser un array</p>
<p>Pour les méthodes static, ce sera&nbsp;: <code>array('NOMDELACLASS', 'NOMDELAMETHODE')</code></p>
<p>Pour les méthodes non-static, ce sera&nbsp;: <code>array(INSTANCEDELACLASS, 'NOMDELAMETHODE')</code></p>
<p>Exemple&nbsp;:</p>
<pre> class maClass {     static function toto()     {         echo 'on a appellé toto';     }     public function totor()     {         echo 'on a appellé totor';     } } //cas static call_user_func(array('maClass', 'toto')); //on a appellé toto //cas non-static $maClass = new maClass(); call_user_func(array($maClass, 'totor')); //on a appellé totor </pre>
<p>J&#8217;espère que ce petit truc vous sera utile.</p>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F72&amp;linkname=PHP%20%3A%20fonction%20callback%20et%20m%C3%A9thode" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F72&amp;linkname=PHP%20%3A%20fonction%20callback%20et%20m%C3%A9thode" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F72&amp;linkname=PHP%20%3A%20fonction%20callback%20et%20m%C3%A9thode" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F72&amp;linkname=PHP%20%3A%20fonction%20callback%20et%20m%C3%A9thode" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F72&amp;linkname=PHP%20%3A%20fonction%20callback%20et%20m%C3%A9thode" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F72&amp;linkname=PHP%20%3A%20fonction%20callback%20et%20m%C3%A9thode" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F72&amp;title=PHP%20%3A%20fonction%20callback%20et%20m%C3%A9thode" id="wpa2a_8"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/72/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend Framework (ZF) : Geshi comme filtre dans ZF</title>
		<link>http://grummfy.be/blog/62#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/62#comments</comments>
		<pubDate>Sat, 04 Aug 2007 00:27:00 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=62</guid>
		<description><![CDATA[Grâce à la libraire Geshi (http://qbnz.com/highlighter/) et à l&#8217;ingéniosité de ZF, colorer tout vos code, facilement, via ce nouveau filtre. Pour l&#8217;utiliser, Télécharger la libraire geshi et décompresser là (dans l&#8217;exemple dans ./../site/lib/geshi/, donc le fichier geshi.php se trouve dans se répertoire et ./../site/lib/geshi/geshi/ contient les fichiers de langues) &#60;?php Zend_Loader::loadClass&#40;'Zend_Filter_Geshi'&#41;; $zfg = new Zend_Filter_Geshi&#40;'php', [...]]]></description>
			<content:encoded><![CDATA[<p>Grâce à la libraire Geshi (<a href="http://qbnz.com/highlighter/" title="http://qbnz.com/highlighter/">http://qbnz.com/highlighter/</a>) et à l&#8217;ingéniosité de ZF, colorer tout vos code, facilement, via ce nouveau filtre.</p>
<p>Pour l&#8217;utiliser, Télécharger la libraire geshi et décompresser là (dans l&#8217;exemple dans ./../site/lib/geshi/, donc le fichier geshi.php se trouve dans se répertoire et ./../site/lib/geshi/geshi/ contient les fichiers de langues)</p>
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span> Zend_Loader::<span style="color: #006600;">loadClass</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Zend_Filter_Geshi'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #0000ff;">$zfg</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Filter_Geshi<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'php'</span>, <span style="color: #ff0000;">'../site/lib/geshi/'</span><span style="color: #66cc66;">&#41;</span>; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$zfg</span>-&gt;<span style="color: #006600;">filter</span><span style="color: #66cc66;">&#40;</span>&lt;&lt;&lt;ABC <span style="color: #000000; font-weight: bold;">&lt;?php</span> Zend_Loader::<span style="color: #006600;">loadClass</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Zend_Filter_Geshi'</span><span style="color: #66cc66;">&#41;</span>; \<span style="color: #0000ff;">$zfg</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Filter_Geshi<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'php'</span>, <span style="color: #ff0000;">'../site/lib/geshi/'</span><span style="color: #66cc66;">&#41;</span>; ABC <span style="color: #66cc66;">&#41;</span>;</pre>
<p>Autre endroit ou trouver ce code&nbsp;: <a href="http://www.z-f.fr/code/detail/17" title="http://www.z-f.fr/code/detail/17">http://www.z-f.fr/code/detail/17</a></p>
<p><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F62&amp;linkname=Zend%20Framework%20%28ZF%29%20%3A%20Geshi%20comme%20filtre%20dans%20ZF" title="Delicious" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F62&amp;linkname=Zend%20Framework%20%28ZF%29%20%3A%20Geshi%20comme%20filtre%20dans%20ZF" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F62&amp;linkname=Zend%20Framework%20%28ZF%29%20%3A%20Geshi%20comme%20filtre%20dans%20ZF" title="Twitter" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F62&amp;linkname=Zend%20Framework%20%28ZF%29%20%3A%20Geshi%20comme%20filtre%20dans%20ZF" title="Facebook" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F62&amp;linkname=Zend%20Framework%20%28ZF%29%20%3A%20Geshi%20comme%20filtre%20dans%20ZF" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_netvibes_share" href="http://www.addtoany.com/add_to/netvibes_share?linkurl=http%3A%2F%2Fgrummfy.be%2Fblog%2F62&amp;linkname=Zend%20Framework%20%28ZF%29%20%3A%20Geshi%20comme%20filtre%20dans%20ZF" title="Netvibes Share" rel="nofollow" target="_blank"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/icons/netvibes.png" width="16" height="16" alt="Netvibes Share"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgrummfy.be%2Fblog%2F62&amp;title=Zend%20Framework%20%28ZF%29%20%3A%20Geshi%20comme%20filtre%20dans%20ZF" id="wpa2a_10"><img src="http://grummfy.be/blog/wp/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/62/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fire Soft Board RC4b Disponible!</title>
		<link>http://grummfy.be/blog/30#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/30#comments</comments>
		<pubDate>Wed, 23 May 2007 15:12:00 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[forum]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sortie]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=30</guid>
		<description><![CDATA[Bonjour,<br />
c'est avec joie que je vous annonce que la <a href="http://fr.wikipedia.org/wiki/Version_d%27un_logiciel#Release_candidate_.28RC.29_ou_pre-release" >Release Candidate</a> 4b de <accronym title="Fire Soft Board">FSB2</accronym> est sortie! ]]></description>
			<content:encoded><![CDATA[<p>Bonjour,<br />
c&#8217;est avec joie que je vous annonce que la <a href="http://fr.wikipedia.org/wiki/Version_d%27un_logiciel#Release_candidate_.28RC.29_ou_pre-release" >Release Candidate</a> 4b de <accronym title="Fire Soft Board">FSB2</accronym> est sortie!<br />
<span id="more-30"></span></p>
<h3>Mais tout d&#8217;abord qu&#8217;est ce que FSB?</h3>
<p>FSB ou  fire soft board, est avant tout un forum! Écrit en php multi-langue et multi-base de donnée!<br />
La version 2, qui continue en parallèle avec la version1, est assez complète. Fsb a tout pour être une usine à gaz, cependant cela n&#8217;en a pas le comportement.<br />
Le mieux est encore de vous laisser découvrir cette merveille.</p>
<h3>Changelog</h3>
<ul>
<li>Ajout de la possibilité de paramétrer les forums de façon à choisir la MAP que l&#8217;on veut lors des réponses</li>
<li>Ajout de la possibilité de désactiver le WYSIWYG sur l&#8217;ensemble du forum</li>
<li>Ajout de la possibilité de différencier les MAJ des MODS à lister dans l&#8217;administration des modules (balise &lt;isUpdate /&gt; dans le header)</li>
<li>Ajout d&#8217;une option de support automatique pour le forum</li>
<li>Corrections orthographiques</li>
<li>Fix de la classe Captcha, qui fonctionne désormais même si la librairie GD est désactivée</li>
<li>Fix des informations sur la MAP en cas de division de sujet</li>
<li>Fix d&#8217;un bug qui empéchait l&#8217;édition avancée des messages dans certaines configurations de droits</li>
<li>Fix d&#8217;un bug SQL sur le déplacement de sujet</li>
<li>Fix d&#8217;un bug sur l&#8217;insertion de smilies dans l&#8217;éditeur WYSIWYG</li>
<li>Fix d&#8217;un bug qui affichait le code HTML de certains FSBcode dans l&#8217;éditeur WYSIWYG</li>
<li>Fix de la configuration de la taille des avatars</li>
<li>Fix du chemin de l&#8217;image blanks.gif dans le fichier pngbehavior.htc</li>
<li>Fix de l&#8217;édition rapide en y mettant correctement les tabindex</li>
<li>Fix des droits sur la recherche</li>
<li>Fix de la restauration après installation de MODS dans l&#8217;administration</li>
</ul>
<h3>Plus d&#8217;info?</h3>
<p><strong><a href="http://www.fire-soft-board.com/fsb/sujet-6820-1.html" hreflang="fr">Voir l&#8217;annonce</a></strong><br />
<strong>Téléchargement</strong>&nbsp;:</p>
<ul>
<li><a href="http://www.fire-soft-board.com/index.php?p=download&amp;mode=release&amp;compress=tgz&amp;id=28">GZIP</a></li>
<li><a href="http://www.fire-soft-board.com/index.php?p=download&amp;mode=release&amp;compress=zip&amp;id=28">ZIP</a></li>
</ul>
<p><strong><a href="http://www.fire-soft-board.com/dl/update/maj_2.0.0.RC4a_to_2.0.0.RC4b/install.xml">Modification manuelle</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/30/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fire Soft Board RC4 Disponible!</title>
		<link>http://grummfy.be/blog/27#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/27#comments</comments>
		<pubDate>Sun, 06 May 2007 21:06:00 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[forum]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sortie]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=27</guid>
		<description><![CDATA[Bonjour,<br />
c'est avec joie que je vous annonce que la <a href="http://fr.wikipedia.org/wiki/Version_d%27un_logiciel#Release_candidate_.28RC.29_ou_pre-release" >Release Candidate</a> 4 de <accronym title="Fire Soft Board">FSB2</accronym> est sortie! ]]></description>
			<content:encoded><![CDATA[<p>Bonjour,<br />
c&#8217;est avec joie que je vous annonce que la <a href="http://fr.wikipedia.org/wiki/Version_d%27un_logiciel#Release_candidate_.28RC.29_ou_pre-release" >Release Candidate</a> 4 de <accronym title="Fire Soft Board">FSB2</accronym> est sortie!<br />
<span id="more-27"></span></p>
<h3>Mais tout d&#8217;abord qu&#8217;est ce que FSB?</h3>
<p>FSB ou  fire soft board, est avant tout un forum! Écrit en php multi-langue et multi-base de donnée!<br />
La version 2, qui continue en parallèle avec la version1, est assez complète. Fsb a tout pour être une usine à gaz, cependant cela n&#8217;en a pas le comportement.<br />
Le mieux est encore de vous laisser découvrir cette merveille.</p>
<h3>Changelog</h3>
<ul>
<li>Ajout d&#8217;information sur les mises à jour dans l&#8217;administration</li>
<li>Ajout de la possibilité de ne pas afficher les bots sur l&#8217;index</li>
<li>Ajout de palettes de couleurs avancées (mooRainbow) sur les FSBcode COLOR / BGCOLOR</li>
<li>Ajout de la raison dans la liste des banissements</li>
<li>Ajout de la possibilité de créer des clefs de langue dans l&#8217;administration des langues</li>
<li>Ajout d&#8217;overflow sur l&#8217;avatar dans les profils et les messages privés</li>
<li>Ajout du log des IP pour les messages privés</li>
<li>Ajout de la possibilité d&#8217;utiliser des FSBcode dans les règles du forum</li>
<li>Ajout du nombre de messages abusifs pour les modérateurs</li>
<li>Ajout du nombre de messages à approuver pour les modérateurs</li>
<li>Ajout de deux nouveaux smilies</li>
<li>Ajout d&#8217;un lien pour ajouter les forums de façon plus pratique dans le gestionaire de forum</li>
<li>Ajout de la possibilité de plier / déplier les catégories dans le gestionaire de forum</li>
<li>Optimisation conséquente de l&#8217;affichage de l&#8217;index (mise en cache dans les forums, des informations du dernier sujet)</li>
<li>Optimisation de la recherche des sujets et des messages des membres</li>
<li>Fix du cache FTP, en ajoutant une vérification de l&#8217;intégrité des données</li>
<li>Fix du contact des administrateurs en mettant le fondateur par défaut</li>
<li>Fix de la CSS pour IE7</li>
<li>Fix d&#8217;un bug sur la position des membres sur le forum, dans l&#8217;administration</li>
<li>Fix du parse des FSBcode IMG et URL</li>
<li>Fix des droits de visibilité de la liste des membres et du profil</li>
<li>Fix de la taille du champ de texte en passant en mode WYSIWYG</li>
<li>Fix d&#8217;un gros bug au niveau des droits</li>
<li>Fix des anniversaires si le champ est vide</li>
<li>Fix d&#8217;un bug sur les quota d&#8217;upload dans la configuration</li>
<li>Fix des droits pour répondre à une news</li>
<li>Fix du FSBcode LIST en cas d&#8217;imbrication avec des listes de numéros</li>
<li>Fix des caractères spéciaux dans les titre des flux RSS</li>
<li>Fix du tri sur les banissements</li>
<li>Fix des titres des pages pour une meilleur référencement</li>
<li>Fix du lien vers le dernier message non lu si celui ci est directement sur la page d&#8217;après</li>
<li>Fix de la popup de chargement des informations envoyées en ajax</li>
<li>Fix des erreurs UTF-8 dans le parse XML des messages (réécriture du parseur XML sans passer par l&#8217;extension XML)</li>
<li>Fix des numéros de page qui ne s&#8217;affichaient pas dans les messages non lus triés par forums</li>
<li>Fix d&#8217;un oublie du nom de la table dans la requête de mise à jour des forums</li>
<li>Fix de la classe GD en ajoutant le support des images BMP</li>
<li>Fix des informations sur la liste des membres en supprimant une mauvaise mise en cache</li>
<li>Fix d&#8217;un bug dans la classe diff, qui ajoutait des doublons lors de la mise en cache</li>
<li>Fix compatibilité SQLite / PostgreSQL</li>
<li>Fix des accents dans le nom des smilies</li>
<li>Fix du parse des smilies en supprimant la casse</li>
<li>Fix de la recherche dans les catégories / sous forums</li>
<li>Fix d&#8217;une bug sur les listes vides</li>
<li>Fix de la mise à jour de la configuration du portail en cas de valeur nulle</li>
<li>Fix du formatage du texte sur l&#8217;éditeur WYSIWYG avec les FSBcode CODE et QUOTE</li>
</ul>
<h3>Plus d&#8217;info?</h3>
<p><strong><a href="http://www.fire-soft-board.com/fsb/sujet-6677-1.html" hreflang="fr">Voir l&#8217;annonce</a></strong><br />
<strong>Téléchargement</strong>&nbsp;: <a href="http://www.fire-soft-board.com/index.php?p=download&amp;mode=release&amp;compress=zip&amp;id=26">ZIP</a> <a href="http://www.fire-soft-board.com/index.php?p=download&amp;mode=release&amp;compress=tgz&amp;id=26">GZIP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/27/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>404 ou page non trouver?</title>
		<link>http://grummfy.be/blog/22#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/22#comments</comments>
		<pubDate>Fri, 13 Apr 2007 15:52:00 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[trucs et astuces]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=22</guid>
		<description><![CDATA[<p>Vous êtes certainement déjà tombé, un jour ou l'autre sur une page non trouvé (page not found, page non trouver, erreur 404).<br />
Parfois très moche, parfois joli voir le message de base du navigateur disant que la page n'a pas été trouvée.</p> <p>Essayons de comprendre le mécanisme et d'éviter cette erreur,<br />
De comprendre comment créer des pages plus évoluée que le simple message de apache ou du navigateur,<br />
Et de voir les erreurs, sur les pages d'erreurs ;), souvent rencontrée!</p>]]></description>
			<content:encoded><![CDATA[<p>Vous êtes certainement déjà tombé, un jour ou l&#8217;autre sur une page non trouvé (page not found, page non trouver, erreur 404).<br />
Parfois très moche, parfois joli voir le message de base du navigateur disant que la page n&#8217;a pas été trouvée.</p>
<p>Essayons de comprendre le mécanisme et d&#8217;éviter cette erreur,<br />
De comprendre comment créer des pages plus évoluée que le simple message de apache ou du navigateur,<br />
Et de voir les erreurs, sur les pages d&#8217;erreurs <img src='http://grummfy.be/blog/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> , souvent rencontrée!</p>
<p><span id="more-22"></span></p>
<h2>Qu&#8217;est-ce qui provoque une erreur 404?</h2>
<p><em>Et surtout comment l&#8217;éviter</em><br />
Normalement une erreur 404 provient lorsque un fichier(page, document, fichiers &#8230;) n&#8217;est pas trouvé.<br />
En pratique c&#8217;est souvent une erreur de lien mal fait, lien vers des fichiers qui n&#8217;existent plus, &#8230; Afin d&#8217;éviter une erreur 404, pouvant vous faire perdre des visiteurs (après tout ce qui reste s&#8217;il voit une bête page disant &laquo;&nbsp;fichier non trouvé!&nbsp;&raquo;).</p>
<ul>
<li>Pensez à tester les liens de votre site.</li>
<li>En cas de changement d&#8217;emplacement des fichiers, plusieurs possibilités s&#8217;offre à vous&nbsp;:
<ul>
<li>Effectuer une redirection (Via entête HTTP) de l&#8217;ancien lien vers le nouveau (pensez aux utilisateurs ayant stocker le dit lien, aux moteurs de recherches vous ayant indexer, &#8230;). Les moteurs de recherches effectueront la mise à jour et au bout d&#8217;un moment vous n&#8217;aurez plus qu&#8217;à utiliser le message décrit ci-après.</li>
<li>Afficher un message (pour l&#8217;utilisateur uniquement puisque le moteur de recherche ne le comprend pas) disant de se rendre à la base du site et de reprendre leur recherche. Ainsi l&#8217;utilisateur retrouvera (ou pas) sa page.</li>
</ul>
</li>
</ul>
<p>Je vous ai cité les deux qui me paraissent facile à mettre en place.</p>
<ul>
<li>Penser a vérifier le listing de vos pages indexer dans les moteurs de recherche, cela évite pas mal de surprise&#8230;.</li>
</ul>
<h2>Création d&#8217;une page d&#8217;erreur personnalisée</h2>
<blockquote><p>Attention il est possible que votre hébergeur ne vous y autorise pas!</p>
</blockquote>
<p>Il vous faut en premier lieux créer un fichier <q>.htaccess</q> dans lequel mettre ce code&nbsp;: <code>ErrorDocument 404 /totor/404.html</code></p>
<h4>Mais que va faire ce bout de code</h4>
<p>Lorsque une erreur 404 se produira, apache va afficher <q>/totor/404.html</q>.</p>
<p>Plus exactement, lorsque vous tapez <q>http://www.monsiteamoi.com/test/pagequiexistepas</q>, apache affichera le contenu de <q>http://www.monsiteamoi.com/totor/404.html</q>, tout en gardant l&#8217;url inchangé.</p>
<p>Cependant afin que les moteurs de recherche comprennent qu&#8217;il y a une erreur une entête HTTP 404 est quand même généré! Il ne vous reste plus qu&#8217;à créer la page 404.html.</p>
<h2>Erreur la plus couramment trouver dans les tutoriaux</h2>
<p>Dans énormément de tutoriaux on trouve cette erreur&nbsp;:</p>
<blockquote><p>Mettre ceci dans votre fichier .htaccess&nbsp;: <q>ErrorDocument 404 http://www.monsiteamoi.com/totor/404.html</q></p>
</blockquote>
<p>Or cela à pour effet de oui afficher la page 404, mais le code HTTP que renvoi la page est 200 (soit que tout va bien) donc les moteurs de recherche (entre-autres) vont continuer à indexer cette page!</p>
<h2>A noter</h2>
<ul>
<li>Les autres erreurs HTTP peuvent être traité de la même manière</li>
<li>Vous pouvez utiliser un script PHP afin de par exemple gérer toutes les erreurs <q>ErrorDocument 404 /error.php?code=404</q></li>
<li>Tester vos entêtes HTTP avec firefox via l&#8217;extension webDevlopper (menu information, entête HTTP)</li>
</ul>
<h2>Quelques liens&nbsp;:</h2>
<ul>
<li><a href="http://fr.wikipedia.org/wiki/Erreur_HTTP_404" hreflang="fr">Erreur HTTP 404</a></li>
<li><a href="http://en.wikipedia.org/wiki/HTTP_404" hreflang="en">HTTP 404</a></li>
<li><a href="http://fr.wikipedia.org/wiki/Liste_des_codes_HTTP" hreflang="fr">Liste des codes HTTP</a></li>
<li><a href="http://www.lightecho.net/404page/404_fame.html" hreflang="en">Les meilleurs pages 404</a></li>
<li><a href="http://www.365questions.org/2006/10/15/is-there-an-art-of-404-pages/" hreflang="en" class="broken_link">Quelques autres page 404 marante</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/22/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jouons aves PHP et la poo</title>
		<link>http://grummfy.be/blog/15#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://grummfy.be/blog/15#comments</comments>
		<pubDate>Sun, 18 Mar 2007 23:22:00 +0000</pubDate>
		<dc:creator>Grummfy</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[jouons]]></category>
		<category><![CDATA[poo]]></category>
		<category><![CDATA[programmation]]></category>

		<guid isPermaLink="false">http://grummfy.be/blog/?p=15</guid>
		<description><![CDATA[<p>Amusons nous avec PHP4, et PHP5 en poo.<br /><br /> Comparons le comportement de ceci :</p> <pre class="code php"><span style="color: rgb(0, 0, 0); font-weight: bold;">class</span> A<br /><span style="color: rgb(102, 204, 102);">{</span><br />    <span style="color: rgb(0, 0, 0); font-weight: bold;">function</span> A<span style="color: rgb(102, 204, 102);">(</span><span style="color: rgb(102, 204, 102);">)</span><br />    <span style="color: rgb(102, 204, 102);">{</span></pre><br />]]></description>
			<content:encoded><![CDATA[<p>Amusons nous avec PHP4, et PHP5 en poo.</p>
<p> Comparons le comportement de ceci :</p>
<pre class="code php"><span style="color: rgb(0, 0, 0); font-weight: bold;">class</span> A<span style="color: rgb(102, 204, 102);">{</span>    <span style="color: rgb(0, 0, 0); font-weight: bold;">function</span> A<span style="color: rgb(102, 204, 102);">(</span><span style="color: rgb(102, 204, 102);">)</span>    <span style="color: rgb(102, 204, 102);">{</span></pre>
<p>
<span id="more-15"></span></p>
<pre class="code php">        <a href="http://www.php.net/echo"><span style="color: rgb(0, 0, 102);">echo</span></a> <span style="color: rgb(255, 0, 0);">'Je me nome A'</span> . <span style="color: rgb(255, 0, 0);">"<span style="color: rgb(0, 0, 153); font-weight: bold;"> </span>"</span>;    <span style="color: rgb(102, 204, 102);">}</span>

    <span style="color: rgb(0, 0, 0); font-weight: bold;">function</span> B<span style="color: rgb(102, 204, 102);">(</span><span style="color: rgb(102, 204, 102);">)</span>    <span style="color: rgb(102, 204, 102);">{</span>        <a href="http://www.php.net/echo"><span style="color: rgb(0, 0, 102);">echo</span></a> <span style="color: rgb(255, 0, 0);">'Je me nome B'</span> . <span style="color: rgb(255, 0, 0);">"<span style="color: rgb(0, 0, 153); font-weight: bold;"> </span>"</span>;    <span style="color: rgb(102, 204, 102);">}</span>

<span style="color: rgb(102, 204, 102);">}</span>&nbsp;<span style="color: rgb(0, 0, 0); font-weight: bold;">class</span> B <span style="color: rgb(0, 0, 0); font-weight: bold;">extends</span> A<span style="color: rgb(102, 204, 102);">{</span>    <span style="color: rgb(0, 0, 0); font-weight: bold;">function</span> C<span style="color: rgb(102, 204, 102);">(</span><span style="color: rgb(102, 204, 102);">)</span>    <span style="color: rgb(102, 204, 102);">{</span>        <a href="http://www.php.net/echo"><span style="color: rgb(0, 0, 102);">echo</span></a> <span style="color: rgb(255, 0, 0);">'Je me nome C'</span> . <span style="color: rgb(255, 0, 0);">"<span style="color: rgb(0, 0, 153); font-weight: bold;"> </span>"</span>;    <span style="color: rgb(102, 204, 102);">}</span><span style="color: rgb(102, 204, 102);">}</span>

<span style="color: rgb(0, 0, 0); font-weight: bold;">class</span> C <span style="color: rgb(0, 0, 0); font-weight: bold;">extends</span> B<span style="color: rgb(102, 204, 102);">{</span>&nbsp;<span style="color: rgb(102, 204, 102);">}</span>&nbsp;<span style="color: rgb(0, 0, 255);">$B</span> = <span style="color: rgb(0, 0, 0); font-weight: bold;">new</span> B<span style="color: rgb(102, 204, 102);">(</span><span style="color: rgb(102, 204, 102);">)</span>;<span style="color: rgb(0, 0, 255);">$C</span> = <span style="color: rgb(0, 0, 0); font-weight: bold;">new</span> C<span style="color: rgb(102, 204, 102);">(</span><span style="color: rgb(102, 204, 102);">)</span>;</pre>
<ul>
<li>en PHP4 :<br />
<blockquote>
<p>Je me nome B<br />
 Je me nome C</p>
</blockquote>
</li>
<li>en PHP5<br />
<blockquote>
<p>Je me nome A <br />Je me nome A</p>
</blockquote>
</li>
</ul>
<p> <ins> Avant tout il faut savoi</ins>r que en PHP, si une class enfant n&#8217;as pas de constructeur défini, c&#8217;est le constructeur parent qui sera appelé.</p>
<p> En PHP5, on peux le voir c&#8217;est effectivement le cas.<br />Mais en PHP4, cela ne semble pas tout a fait juste.</p>
<p>Changeons un peu le code, en remplaçant :<br /><code> function C()</code><br />par<br /><code>function Cbis()</code> <br />Et là le résultat pour PHP4 change :<br />
<blockquote>
<p>Je me nome B<br />
 Je me nome B</p>
</blockquote>
<p>C&#8217;est toujours utile a savoir&#8230; et surtotu cela peux éviter de longue heures de debug &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://grummfy.be/blog/15/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 3.764 seconds -->

