<?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>Webinside - Blog d'Hervé Delvaux &#187; Tutorial</title>
	<atom:link href="http://www.webinside.be/category/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webinside.be</link>
	<description></description>
	<lastBuildDate>Fri, 03 Sep 2010 08:52:35 +0000</lastBuildDate>
	<language>fr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Activé SSH sous ESXi</title>
		<link>http://www.webinside.be/active-ssh-sous-esxi/</link>
		<comments>http://www.webinside.be/active-ssh-sous-esxi/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 19:55:43 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[Serveur]]></category>
		<category><![CDATA[Tuto Serveur]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Virtualisation]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[PuTTY]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.webinside.be/?p=608</guid>
		<description><![CDATA[Pour activer SSh sous ESXi, vous devez vous rendre sur la Console d&#8217;ESXi : Presser les touches ALT + F1 Taper : unsupported Indiquer votre mot de passe root Taper la commande : vi /etc/inetd.conf (pour éditer le fichier de configuration) Chercher les lignes commencant par #ssh Décommenter les lignes (en retirant le # devant [...]]]></description>
			<content:encoded><![CDATA[<p>Pour activer <a href="http://fr.wikipedia.org/wiki/Secure_Shell">SSh</a> sous <a href="http://www.vmware.com/products/vsphere-hypervisor/index.html">ESXi</a>, vous devez vous rendre sur la Console d&#8217;ESXi :</p>
<ul>
<li> Presser les touches <strong>ALT + F1</strong></li>
<li> Taper : <strong><em>unsupported</em></strong></li>
<li> Indiquer votre mot de passe root</li>
<li> Taper la commande : <strong><em>vi /etc/inetd.conf</em></strong> (pour éditer le fichier de configuration)</li>
<li> Chercher les lignes commencant par <strong>#ssh</strong></li>
<li> Décommenter les lignes (en retirant le # devant ces lignes)</li>
<li> Sauver le fichier en tapant : <strong><em>:wq!</em></strong></li>
<li> Redémarrer les servcices avec <strong><em>/sbin/services.sh restart</em></strong></li>
</ul>
<p>Il ne vous reste plus qu&#8217;à vous connecter sur votre serveur ESXi avec <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">putty</a> <img src='http://www.webinside.be/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><em>Remarque : Pour revenir à la console standard, il vous suffit de presser les touches : <strong>ALT + F2</strong></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webinside.be/active-ssh-sous-esxi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework : reCAPTCHA dans un formulaire</title>
		<link>http://www.webinside.be/zend-framework-recaptcha-dans-un-formulaire/</link>
		<comments>http://www.webinside.be/zend-framework-recaptcha-dans-un-formulaire/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 10:46:16 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Php / mySql]]></category>
		<category><![CDATA[Programmation]]></category>
		<category><![CDATA[Tuto Zend Framework]]></category>
		<category><![CDATA[formulaire]]></category>
		<category><![CDATA[reCaptcha]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Form]]></category>

		<guid isPermaLink="false">http://www.webinside.be/?p=343</guid>
		<description><![CDATA[Pour protéger ses formulaires contre le bot, spammer etc&#8230;, on utilise un captcha. Ce système permet de différencier de manière automatisée un utilisateur humain d&#8217;un ordinateur. Nous allons utiliser Zend_Service_ReCaptcha qui fournit un client pour le Service Web reCAPTCHA. Qu&#8217;est ce que reCAPTCHA ? reCAPTCHA est un système mettant à profit les capacités de reconnaissance [...]]]></description>
			<content:encoded><![CDATA[<p>Pour protéger ses formulaires contre le bot, spammer etc&#8230;, on utilise un captcha. Ce système permet de différencier de manière automatisée un utilisateur humain d&#8217;un ordinateur.</p>
<p>Nous allons utiliser <em>Zend_Service_ReCaptcha</em> qui fournit un client pour le <a href="http://recaptcha.net/">Service Web reCAPTCHA</a>.</p>
<p><strong>Qu&#8217;est ce que reCAPTCHA ?</strong></p>
<blockquote><p><img class="alignright size-full wp-image-357" style="margin: 8px;" title="recaptcha-example" src="http://www.webinside.be/wp-content/uploads/2009/01/recaptcha-example.gif" alt="recaptcha-example" width="314" height="125" /><br />
reCAPTCHA est un système mettant à profit les capacités de reconnaissance des utilisateurs humains mobilisées par les tests Captcha, pour améliorer par la même occasion le processus de numérisation de livres, là où échouent les systèmes de reconnaissance optique de caractères (OCR).</p>
<p>L&#8217;idée est de rendre utile une tâche qui peut sembler rébarbative. La technique tient du crowdsourcing.</p>
<p>Concrètement, par rapport à un processus habituel d&#8217;authentification par Captcha, ce ne sont pas un mais deux mots qui sont présentés à l&#8217;utilisateur. L&#8217;un d&#8217;eux est un Captcha habituel, dont la solution est par conséquent connue de manière certaine ; seul l&#8217;autre est issu de la numérisation d&#8217;un livre : c&#8217;est celui dont la solution est incertaine voire inconnue et que l&#8217;utilisateur va aider à résoudre.</p>
<p>Le système part du principe que si les utilisateurs résolvent correctement le Captcha habituel, alors ils ont aussi déchiffré correctement le mot inconnu. Néanmoins, un mot n&#8217;est considéré comme vraiment reconnu que si plusieurs utilisateurs l&#8217;ont vérifié en obtenant le même résultat.</p></blockquote>
<p><strong>Source</strong> : <a href="http://fr.wikipedia.org/wiki/ReCAPTCHA">Wikipedia</a></p>
<p><span id="more-343"></span></p>
<p>Pour utiliser le service reCAPTCHA, vous devez <a href="https://admin.recaptcha.net/accounts/signup/?next=">créer un compte</a> et enregistrer un ou plusieurs domaines d&#8217;utilisation afin de générer une clé publique et une privée.</p>
<p><strong>Utilisation de reCAPTCHA dans un Zend_Form</strong> :</p>

<div class="wp_codebox"><table><tr id="p3432"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p343code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> My_Form <span style="color: #000000; font-weight: bold;">extends</span> Zend_Form
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<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;">//...</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Captcha</span>
		<span style="color: #000088;">$pubKey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'VOTRE_CLE_PUBLIC'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$privKey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'VOTRE_CLE_PRIVEE'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$recaptcha</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Service_ReCaptcha<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pubKey</span><span style="color: #339933;">,</span> <span style="color: #000088;">$privKey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$adapter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Captcha_ReCaptcha<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$adapter</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setService<span style="color: #009900;">&#40;</span><span style="color: #000088;">$recaptcha</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$captcha</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Form_Element_Captcha<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'recaptcha'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">&quot;Anti-spam&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'captcha'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$adapter</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;">-&amp;</span>gt<span style="color: #339933;">;</span>addElement<span style="color: #009900;">&#40;</span><span style="color: #000088;">$captcha</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//...</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><em>Notes</em> : N&#8217;oubliez pas de changer VOTRE_CLE_PUBLIC et VOTRE_CLE_PRIVEE par celles fournie par reCAPTCHA.</p>
<p>Pour plus de détails concernant l&#8217;utilisation de formulaire, reCAPTCHA,&#8230; je vous invite à consulter la documentation de Zend Framework :</p>
<ul>
<li><a href="http://framework.zend.com/manual/fr/zend.captcha.adapters.html#zend.captcha.adapters.recaptcha"> Zend_Captcha_ReCaptcha</a></li>
<li><a href="http://framework.zend.com/manual/fr/zend.form.standardElements.html#zend.form.standardElements.captcha">Zend_Form_Element_Captcha</a></li>
<li><a href="http://framework.zend.com/manual/fr/zend.service.recaptcha.html">Zend_Service_Recaptcha</a></li>
<li><a href="http://framework.zend.com/manual/fr/zend.form.html">Zend_Form</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.webinside.be/zend-framework-recaptcha-dans-un-formulaire/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Les vues (view) en MySQL 5</title>
		<link>http://www.webinside.be/les-vues-en-mysql-5/</link>
		<comments>http://www.webinside.be/les-vues-en-mysql-5/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 21:12:15 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[Php / mySql]]></category>
		<category><![CDATA[Sceencast]]></category>
		<category><![CDATA[Tuto MySQL]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Screencast]]></category>
		<category><![CDATA[vue]]></category>

		<guid isPermaLink="false">http://www.webinside.be/?p=231</guid>
		<description><![CDATA[Les vues sont implémentées en version 5 de MySQL, elles sont disponibles depuis la version 5.0.1. Qu&#8217;est ce qu&#8217;une vue Les vues sont des tables virtuelles créées à l&#8217;aide d&#8217;une requête SELECT. Elles ne stockent pas les données qu&#8217;elles contiennent. Seule la requête permettant de les créer est conservée. Des vues pourquoi faire ? Une [...]]]></description>
			<content:encoded><![CDATA[<p>Les vues sont implémentées en <a href="http://dev.mysql.com/doc/refman/5.0/fr/views.html">version 5 de MySQL</a>, elles sont disponibles depuis la version 5.0.1.</p>
<p><strong>Qu&#8217;est ce qu&#8217;une vue</strong></p>
<p>Les vues sont des tables virtuelles créées à l&#8217;aide d&#8217;une requête SELECT.<br />
Elles ne stockent pas les données qu&#8217;elles contiennent. Seule la requête permettant de les créer est conservée.</p>
<div style="text-align:center;"><object width="480" height="405"><param name="movie" value="http://www.dailymotion.com/swf/kGgxoTrZBo5p2SRmGg&#038;related=1&#038;canvas=medium"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/kGgxoTrZBo5p2SRmGg&#038;related=1&#038;canvas=medium" type="application/x-shockwave-flash" width="480" height="405" allowFullScreen="true" allowScriptAccess="always"></embed></object></div>
<p><span id="more-231"></span></p>
<p><strong>Des vues pourquoi faire ?</strong></p>
<p>Une vue peut donc être, une jointure entre différentes tables, l&#8217;extraction de certaines colonnes,&#8230;</p>
<p>Les vues peuvent être utilisées pour différentes raisons :</p>
<ul>
<li> Restreindre l&#8217;accès à certaine valeur en personnalisant l&#8217;affichage des informations suivant le type d&#8217;utilisateur.</li>
<li>Masquer la complexité d&#8217;un schéma.</li>
<li>Permettre de manipuler des valeurs calculées à partir d&#8217;autres valeurs du schéma.</li>
<li>Conserver la structure d&#8217;une table si elle doit être modifiée. pour ne pas devoir changer les requêtes du côté applicatif.</li>
</ul>
<p><strong>Syntaxe</strong></p>
<p><strong>Création d&#8217;une vue</strong> :</p>

<div class="wp_codebox"><table><tr id="p2317"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p231code7"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span>ALGORITHM <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>MERGE <span style="color: #66cc66;">|</span> TEMPTABLE<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">VIEW</span> view_name
<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>column_list<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> select_statement <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #66cc66;">&#91;</span>CASCADED <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">LOCAL</span><span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">CHECK</span> <span style="color: #993333; font-weight: bold;">OPTION</span><span style="color: #66cc66;">&#93;</span></pre></td></tr></table></div>

<p>Cette commande crée une nouvelle vue, ou remplace une vue existante si la clause <em>OR REPLACE</em> est fournie. La clause <em>select_statement</em> est une commande SELECT qui fournit la définition de la vue. La liste optionnelle de colonnes peut être fournie pour définir explicitement les noms des colonnes.</p>
<p><strong>Modification d&#8217;une vue</strong> :</p>

<div class="wp_codebox"><table><tr id="p2318"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p231code8"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">VIEW</span> view_name <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>column_list<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span> select_statement</pre></td></tr></table></div>

<p>Cette commande modifie la définition d&#8217;une vue.<br />
<em>select_statement</em> est le même que pour CREATE VIEW.</p>
<p><strong>Supprimer une vue</strong> :</p>

<div class="wp_codebox"><table><tr id="p2319"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p231code9"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">VIEW</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span><span style="color: #66cc66;">&#93;</span>
    view_name <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">,</span> view_name<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">...</span>
    <span style="color: #66cc66;">&#91;</span>RESTRICT <span style="color: #66cc66;">|</span> CASCADE<span style="color: #66cc66;">&#93;</span></pre></td></tr></table></div>

<p><em>DROP VIEW</em> supprime une ou plusieurs vues. Vous devez avoir les droits de <em>DROP</em> pour chaque vue.</p>
<p><strong>Voir la définition de la vue</strong> :</p>

<div class="wp_codebox"><table><tr id="p23110"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p231code10"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SHOW</span> <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">VIEW</span> view_name</pre></td></tr></table></div>

<p>Cette commande montre la commande <em>CREATE VIEW</em> qui créera la vue spécifiée.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webinside.be/les-vues-en-mysql-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tutoriels vidéos Google Webmaster Tools</title>
		<link>http://www.webinside.be/tutoriels-videos-google-webmaster-tools/</link>
		<comments>http://www.webinside.be/tutoriels-videos-google-webmaster-tools/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 22:21:23 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Vidéo]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[webmaster]]></category>
		<category><![CDATA[Webmasters tools]]></category>

		<guid isPermaLink="false">http://www.webinside.be/?p=176</guid>
		<description><![CDATA[Google vient de lancer une série de tutoriels vidéos concernant Google Webmaster Tools. Ces vidéos traiteront des sujets suivant : Video 1: Getting started, signing in, benefits of verifying a site Video 2: Setting preferences for crawling and indexing Video 3: Creating and submitting Sitemaps Video 4: Removing and preventing your content from being indexed [...]]]></description>
			<content:encoded><![CDATA[<p>Google vient de lancer une série de tutoriels vidéos concernant <a href="https://www.google.com/webmasters/tools/docs/fr/about.html">Google Webmaster Tools</a>.</p>
<p>Ces vidéos traiteront des sujets suivant :</p>
<blockquote>
<ul>
<li> Video 1: Getting started, signing in, benefits of verifying a site</li>
<li>Video 2: Setting preferences for crawling and indexing</li>
<li>Video 3: Creating and submitting Sitemaps</li>
<li>Video 4: Removing and preventing your content from being indexed</li>
<li>Video 5: Utilizing the Diagnostics, Statistics and Links sections</li>
<li>Video 6: Communicating between Webmasters and Google</li>
</ul>
</blockquote>
<p><strong>Source</strong> : <a href="http://googlewebmastercentral.blogspot.com/2008/09/webmaster-tools-made-easier-in-french.html">googlewebmastercentral.blogspot.com</a></p>
<p>Ces tutoriels sont disponible en <a href="http://it.youtube.com/watch?v=qQqcQd4-jEw&amp;fmt=18">Italien</a>, <a href="http://es.youtube.com/watch?v=fzYdQfX6YWo&amp;fmt=18">Espagnol</a>, <a href="http://de.youtube.com/watch?v=gbv0I-M0Mak&amp;fmt=18">Allemand</a> ainsi qu&#8217;en <a href="http://fr.youtube.com/watch?v=N_2DaD9QTYU&amp;fmt=18">Français</a> (c&#8217;est pas beau la vie ?).</p>
<p>Pour le moment, seul le tutoriel 1 est disponible.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/N_2DaD9QTYU&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/N_2DaD9QTYU&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webinside.be/tutoriels-videos-google-webmaster-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mise en place d&#8217;un VPN</title>
		<link>http://www.webinside.be/mise-en-place-dun-vpn/</link>
		<comments>http://www.webinside.be/mise-en-place-dun-vpn/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 21:35:57 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[Tuto Linux]]></category>
		<category><![CDATA[Tuto Réseaux]]></category>
		<category><![CDATA[Tuto Serveur]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Reseau]]></category>
		<category><![CDATA[VPN]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.webinside.be/?p=154</guid>
		<description><![CDATA[Qu’est ce qu’un VPN (Virtual Private Network) Un VPN (Virtual Private Network), réseau virtuel privé, est une sorte de &#171;&#160;tunnel&#160;&#187; permettant le passage de communications privées à travers une infrastructure partagée. Celui-ci permet donc de relié deux réseaux &#171;&#160;physiques&#160;&#187; (réseaux locaux) par une liaison non fiable (ex: Internet) de manière sécurisé. Pourquoi avoir mis en [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Qu’est ce qu’un VPN (Virtual Private Network)</strong><br />
Un VPN (<a href="http://fr.wikipedia.org/wiki/R%C3%A9seau_priv%C3%A9_virtuel">Virtual Private Network</a>), réseau virtuel privé, est une sorte de &laquo;&nbsp;tunnel&nbsp;&raquo; permettant le passage de communications privées à travers une infrastructure partagée. Celui-ci permet donc de relié deux réseaux &laquo;&nbsp;physiques&nbsp;&raquo; (réseaux locaux) par une liaison non fiable (ex: Internet) de manière sécurisé.</p>
<p><strong>Pourquoi avoir mis en place un vpn ?</strong><br />
Dans mon cas, le VPN me permet de me connecter au réseau de ma boite et d’accéder aux différentes ressources et serveurs (tel que le serveur exchange, les serveurs de développement,…) comme si mon ordinateur faisait parti du réseau local de l&#8217;entreprise.<br />
De plus, il n’y a plus qu’un seul port ouvert, celui du vpn. Le firewall bloque tout le reste se qui permet de ne pas avoir trop de porte ouverte accessible d’Internet et donc de ce fait d’augmenter la sécurité du réseau de l’entreprise.</p>
<p><strong>Mise en place d’un VPN</strong><br />
Pour ce tutorial, je pars du principe que le serveur tourne sous la distribution Linux Gentoo et que le(s) client(s) tourne(nt) sous Windows.<br />
Il va de soit que rien ne vous empêche d’adapter ce tutorial pour une autre distribution ou pour Windows.</p>
<p><strong>Installation d’openvpn</strong><br />
Pour la mise en place de notre vpn, nous allons utiliser openvpn qui est comme son nom l’indique un outil open source utilisé pour construire des VPNs. Son rôle est de &laquo;&nbsp;tunneliser&nbsp;&raquo;, de manière sécurisée, des données sur un seul port TCP/UDP à travers un réseau non sûr comme Internet et ainsi établir des VPNs.</p>
<p><span id="more-154"></span></p>
<p>Pour installer openvpn sur notre <a href="http://www.gentoo.org/">Gentoo</a>, nous allons taper la commande suivante :</p>

<div class="wp_codebox"><table><tr id="p15425"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p154code25"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># emerge openvpn</span></pre></td></tr></table></div>

<p>(sous <a href="http://www.debian.org/index.fr.html">debian</a> nous aurions tapé : apt-get install openvpn)</p>
<p><strong>Création des clés</strong><br />
Une fois openvpn installé, nous allons devoir créer des clés pour le serveur et le client. On se place dans le bon répertoire à l&#8217;aide de la commande :</p>

<div class="wp_codebox"><table><tr id="p15426"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p154code26"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cd /usr/share/openvpn/easy-rsa/</span></pre></td></tr></table></div>

<p>Et on édite le fichier vars qui contient les variables d&#8217;openvpn à l&#8217;aide de :</p>

<div class="wp_codebox"><table><tr id="p15427"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p154code27"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># nano vars</span></pre></td></tr></table></div>

<p>Voici un exemple variables :</p>

<div class="wp_codebox"><table><tr id="p15428"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p154code28"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">KEY_COUNTRY</span>=<span style="color: #ff0000;">&quot;BE&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">KEY_PROVINCE</span>=<span style="color: #ff0000;">&quot;Belgique&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">KEY_CITY</span>=<span style="color: #ff0000;">&quot;Liège&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">KEY_ORG</span>=<span style="color: #ff0000;">&quot;maSociete&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">KEY_EMAIL</span>=<span style="color: #ff0000;">&quot;monMail@maSociete.com&quot;</span></pre></td></tr></table></div>

<p>On exécute ensuite les commandes suivantes pour initialiser les variables d&#8217;environnement et supprimer d&#8217;éventuelles anciennes clés</p>

<div class="wp_codebox"><table><tr id="p15429"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p154code29"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># source ./vars</span>
<span style="color: #666666; font-style: italic;"># ./clean-all</span></pre></td></tr></table></div>

<p><strong>Génération des clés du Master CA (Autorité de certificat)</strong></p>

<div class="wp_codebox"><table><tr id="p15430"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p154code30"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ./build-ca</span></pre></td></tr></table></div>

<p>Vous devrez répondre à différentes questions et les clés seront générées dans le répertoire keys : ca.crt et ca.key.</p>
<p><strong>Génération des clés du serveur</strong><br />
Maintenant que votre VPN a les clés du CA, il faut générer les clés du serveur</p>

<div class="wp_codebox"><table><tr id="p15431"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p154code31"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ./build-key-server nom_du_serveur.com</span></pre></td></tr></table></div>

<p><em>nom_du_serveur.com</em> représente le nom de domaine du serveur.</p>
<p>Les clés du serveur seront également générées dans le répertoire keys/ : nom_du_serveur.com.crt et nom_du_serveur.com.key.</p>
<p><strong>Génération de clés pour le(s) client(s)</strong></p>

<div class="wp_codebox"><table><tr id="p15432"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p154code32"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ./build-key client</span></pre></td></tr></table></div>

<p><em>client</em> représente le nom du client</p>
<p>Vous pouvez répéter cette opération pour chaque client que vous souhaiter ajouter au VPN.</p>
<p><strong>Génération des paramètres Diffie Hellman</strong></p>

<div class="wp_codebox"><table><tr id="p15433"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p154code33"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ./build-dh</span></pre></td></tr></table></div>

<p>Pour résumé, voici la liste des fichiers qui ont été générés :</p>
<ul>
<li><strong>ca.crt</strong> : est le certificat du Master CA.</li>
<li><strong>ca.key</strong> : est la clé du Master CA.</li>
<li><strong>dh1024.pem</strong> : est les paramètres Diffie Hellman. Ce fichier doit rester sur le serveur.</li>
<li><strong>nom_du_serveur.com.crt</strong> : c’est le certificat du serveur.</li>
<li><strong>nom_du_serveur.com.key</strong> : c’est la clés de votre serveur.</li>
<li><strong>client.crt</strong> : est le certificat d’un de vos clients.</li>
<li><strong>client.key</strong> : est la clé d’un de vos clients.</li>
</ul>
<p>Les <strong>.key</strong> doivent rester secret.<br />
<strong>ca.crt</strong> doit être installé sur chaque client ainsi que sur le serveur<br />
<strong>client(.crt|.key)</strong> est a installer sur le client.<br />
<strong>nom_du_serveur.com(.crt|.key)</strong> est a installer sur le serveur.</p>
<p><strong>Configuration du serveur</strong><br />
Pour configurer le serveur, nous allons éditer le fichier /etc/openvpn/openvpn.conf</p>

<div class="wp_codebox"><table><tr id="p15434"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p154code34"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># nano /etc/openvpn/openvpn.conf</span></pre></td></tr></table></div>

<p>Voici un exemple de configuration :</p>

<div class="wp_codebox"><table><tr id="p15435"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p154code35"><pre class="bash" style="font-family:monospace;">port <span style="color: #000000;">1194</span>							<span style="color: #666666; font-style: italic;"># les clients se connecteront à ce port - votre firewall doit permettre cela</span>
proto udp							<span style="color: #666666; font-style: italic;"># protocole utilisé dans la connexion</span>
ca <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>easy-rsa<span style="color: #000000; font-weight: bold;">/</span>keys<span style="color: #000000; font-weight: bold;">/</span>ca.crt			<span style="color: #666666; font-style: italic;"># certificat du CA</span>
cert <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>easy-rsa<span style="color: #000000; font-weight: bold;">/</span>keys<span style="color: #000000; font-weight: bold;">/</span>nom_du_serveur.com.crt	<span style="color: #666666; font-style: italic;"># certificat du serveur</span>
key <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>easy-rsa<span style="color: #000000; font-weight: bold;">/</span>keys<span style="color: #000000; font-weight: bold;">/</span>nom_du_serveur.com.key	<span style="color: #666666; font-style: italic;"># clé privée du serveur</span>
dev tun                 					<span style="color: #666666; font-style: italic;"># méthode &quot;routing&quot;</span>
dh <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>easy-rsa<span style="color: #000000; font-weight: bold;">/</span>keys<span style="color: #000000; font-weight: bold;">/</span>dh1024.pem      		<span style="color: #666666; font-style: italic;"># paramètres Diffie Hellman</span>
server 10.8.0.0 255.255.255.0         				<span style="color: #666666; font-style: italic;"># sous-réseau que constituera le réseau virtuel</span>
push <span style="color: #ff0000;">&quot;route 192.168.0.0 255.255.255.0&quot;</span>         			<span style="color: #666666; font-style: italic;"># ajoute sur le client la route du réseau du serveur</span>
ifconfig-pool-persist ipp.txt           			<span style="color: #666666; font-style: italic;"># permet de réattribuer la même adresse à chaque client</span>
<span style="color: #c20cb9; font-weight: bold;">ping</span> <span style="color: #000000;">10</span>         						<span style="color: #666666; font-style: italic;"># utile pour garder la connexion active au travers de certains types de firewall</span>
ping-restart <span style="color: #000000;">60</span> 						<span style="color: #666666; font-style: italic;"># réinitialise la connexion si le délai est dépassé</span>
comp-lzo        						<span style="color: #666666; font-style: italic;"># compression des paquets</span>
user nobody     						<span style="color: #666666; font-style: italic;"># une fois démarré, l'appartenance du processus passe de l'utilisateur &quot;root&quot; à</span>
group nogroup   						<span style="color: #666666; font-style: italic;"># &quot;nobody&quot; et du groupe &quot;root&quot; à &quot;nogroup&quot;. Ainsi, si le processus est compromis, aucun dommage ne pourra être causé avec les privilèges du super-utilisateur</span>
persist-key     						<span style="color: #666666; font-style: italic;"># ne doit pas relire la clé en cas de réinitialisation de la connexion</span>
persist-tun     						<span style="color: #666666; font-style: italic;"># ne doit pas reconfigurer l'interface en cas de réinitialisation de la connexion</span>
status openvpn-status.log 					<span style="color: #666666; font-style: italic;"># fichier de log</span>
verb <span style="color: #000000;">3</span>          						<span style="color: #666666; font-style: italic;"># niveau de verbosité des log</span></pre></td></tr></table></div>

<p>Si pour une raison ou une autre, vous voulez utiliser la connexion Internet du réseau distant, vous pouvez rajouter l&#8217;option suivante dans le fichier de configuration :</p>

<div class="wp_codebox"><table><tr id="p15436"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p154code36"><pre class="bash" style="font-family:monospace;">push <span style="color: #ff0000;">&quot;redirect-gateway&quot;</span></pre></td></tr></table></div>

<p>Si vous devez spécifier un serveur DNS et WINS vous pouvez le faire au moyen des lignes suivant</p>

<div class="wp_codebox"><table><tr id="p15437"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p154code37"><pre class="bash" style="font-family:monospace;">push <span style="color: #ff0000;">&quot;dhcp-option DNS 192.168.0.10&quot;</span>
push <span style="color: #ff0000;">&quot;dhcp-option WINS 192.168.0.10&quot;</span></pre></td></tr></table></div>

<p>Où 192.168.0.10 représente l&#8217;adresse des serveurs.</p>
<p><strong>Configuration du client</strong><br />
Pour notre client, nous allons télécharger openvpn pour Windows sur le <a href="http://openvpn.net/index.php/downloads.html">site d&#8217;openvpn</a>.<br />
Nous prendrons la dernière version disponible – à l&#8217;heure où j&#8217;écris ce tutorial cette version est : <em>OpenVPN 2.1_rc7</em>.</p>
<p><strong>Certificats et clés</strong><br />
Une fois openvpn installé, nous allons le configurer. Nous allons nous rendre dans le répertoire C:\Program Files\OpenVPN\config où il faudra copier les fichiers ca.crt, client.key ainsi que client.crt que nous avons générés précédemment sur le serveur.</p>
<p>Ensuite, il ne nous restera plus qu&#8217;à créer le fichier de configuration du client qui se nomera client.ovpn</p>
<p>Voici un exemple de config de ce fichier :</p>

<div class="wp_codebox"><table><tr id="p15438"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p154code38"><pre class="bash" style="font-family:monospace;">client                  		<span style="color: #666666; font-style: italic;"># spécifie à openvpn de fonctionner en mode client</span>
remote nom_du_serveur.com <span style="color: #000000;">1194</span>		<span style="color: #666666; font-style: italic;"># nom_du_serveur.com est soit l'IP du serveur, soit son nom d'hôte. Votre firewall doit permettre la connexion vers l'extérieur sur le port du serveur, ici 1194</span>
proto udp               		<span style="color: #666666; font-style: italic;"># protocole utilisé dans la connexion</span>
resolv-retry infinite   		<span style="color: #666666; font-style: italic;"># tentera indéfiniment de résoudre l'IP du serveur hôte en cas d'échec</span>
nobind                  		<span style="color: #666666; font-style: italic;"># spécifie de ne pas se lier à une adresse et un port local</span>
ns-cert-type server     		<span style="color: #666666; font-style: italic;"># vérifie que le certificat du serveur est bien un certificat de serveur et ainsi évite de se connecter à un client qui se ferait passer pour le serveur avec son certificat de client</span>
ca keys<span style="color: #000000; font-weight: bold;">/</span>ca.crt          		<span style="color: #666666; font-style: italic;"># certificat du CA</span>
cert keys<span style="color: #000000; font-weight: bold;">/</span>client1.crt   		<span style="color: #666666; font-style: italic;"># certificat du client1</span>
key keys<span style="color: #000000; font-weight: bold;">/</span>client1.key    		<span style="color: #666666; font-style: italic;"># clé privée du client1</span>
dev tun                 		<span style="color: #666666; font-style: italic;"># méthode par &quot;routing&quot;</span>
comp-lzo        			<span style="color: #666666; font-style: italic;"># compression des paquets</span>
persist-key     			<span style="color: #666666; font-style: italic;"># ne doit pas relire la clé en cas de réinitialisation de la connexion</span>
persist-tun     			<span style="color: #666666; font-style: italic;"># ne doit pas reconfigurer l'interface en cas de réinitialisation de la connexion</span>
verb <span style="color: #000000;">3</span>          			<span style="color: #666666; font-style: italic;"># niveau de verbosité des log</span></pre></td></tr></table></div>

<p>Une fois toute ces opérations réalisé, il nous suffit d&#8217;exécuter le programme openvpn-gui qui fera apparaitre une petite icône (représentant 2 ordinateurs) dans le system tray.<br />
Un double clique sur celle-ci nous connectera à notre VPN et nous aurons donc accès au réseau local distant.</p>
<p>J&#8217;espère que ce tutorial vous aura plus et permit de mettre en place votre VPN.<br />
N&#8217;hésitez pas à poster un message dans les commentaires pour toutes questions ou remarques éventuelles.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webinside.be/mise-en-place-dun-vpn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transactions dans SGBD à l&#8217;aide de Zend Framework</title>
		<link>http://www.webinside.be/transactions-dans-sgbd-a-laide-de-zend-framework/</link>
		<comments>http://www.webinside.be/transactions-dans-sgbd-a-laide-de-zend-framework/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 15:22:34 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[Tuto MySQL]]></category>
		<category><![CDATA[Tuto Php]]></category>
		<category><![CDATA[Tuto Zend Framework]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[transaction]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.webinside.be/?p=153</guid>
		<description><![CDATA[Ce petit tutorial qui concerne les transactions à l&#8217;aide de Zend Framework est basé sur les versions suivante : MySQL 5 Php 5 Zend Framework 1.5.2 Les transactions dans une base de données Les bases de données définissent les transactions comme étant des unités logiques de travail qui peuvent êtres validées (commited) ou annulées (rolled [...]]]></description>
			<content:encoded><![CDATA[<p>Ce petit tutorial qui concerne les transactions à l&#8217;aide de Zend Framework est basé sur les versions suivante :</p>
<ul>
<li><a href="http://www.mysql.fr/">MySQL 5</a></li>
<li><a href="http://www.php.net/">Php 5</a></li>
<li><a href="http://framework.zend.com/manual/fr">Zend Framework 1.5.2</a></li>
</ul>
<p><strong>Les transactions dans une base de données</strong></p>
<blockquote><p>Les bases de données définissent les transactions comme étant des unités logiques de travail qui peuvent êtres validées (commited) ou annulées (rolled back) en tant qu&#8217;une seule opération, même sur de multiples tables. Toutes les requêtes aux bases de données sont considérées comme faisant partie d&#8217;une transaction, même si le driver de base de données fait ceci implicitement. Ceci s&#8217;appelle le mode auto-commit, dans lequel le driver de base de données créer une transaction pour chaque requête executée et la valide. Par défaut toutes les classes Zend_Db_Adapter fonctionnent en mode auto-commit.</p></blockquote>
<p>Source : <a href="http://framework.zend.com/manual/fr/zend.db.html#zend.db.adapter.transactions">Zend Framework</a></p>
<p>Vous l&#8217;aurez compris, les transactions représentes un groupe de requêtes qui pourra être validé si tout se passe bien ou dans la cas contraire annulé.</p>
<p><span id="more-153"></span></p>
<p>Pour diverses raisons, il peut être utile d&#8217;effectuer une transaction vers une base de données.<br />
Il va de soit que pour utiliser les transactions, votre SGBD et votre moteur de stockage doivent pouvoir les gérer. Ce qui est le cas d&#8217;INNODB pour MySQL mais pas <del datetime="2008-07-11T14:09:42+00:00">encore</del> pour MyISAM.</p>
<p>Donc si votre moteur de stockage est MyISAM, vous devrez convertir les tables qui seront concernées par vos futurs transactions.</p>
<p><strong>Changement du moteur de stockage</strong><br />
On peut changer dynamiquement le moteur de stockage à l&#8217;aide de la commande ALTER TABLE.</p>
<p>Pour passer le moteur de stockage de la table leNomDeMaTable en INNODB nous effectuerons la commande sql suivante :</p>

<div class="wp_codebox"><table><tr id="p15343"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p153code43"><pre class="sql" style="font-family:monospace;">    <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> leNomDeMaTable ENGINE<span style="color: #66cc66;">=</span>INNODB;</pre></td></tr></table></div>

<p>Pour le passer en MyISAM :</p>

<div class="wp_codebox"><table><tr id="p15344"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p153code44"><pre class="sql" style="font-family:monospace;">    <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> maTable2 ENGINE<span style="color: #66cc66;">=</span>MYISAM;</pre></td></tr></table></div>

<p><strong>Transactions à l&#8217;aide de Zend Framework</strong><br />
Maitenant que notre SGBD gère les transactions, il va falloir spécifier manuellement le démarrage de la transaction à l&#8217;aide de <em>beginTransaction()</em>. Toutes les requêtes qui suivront feront parties de celle-ci tant que la transaction ne sera pas annulée avec <em>rollBack()</em> ou validée par un <em>commit()</em>.</p>
<p>Le canevas de base sera donc :</p>

<div class="wp_codebox"><table><tr id="p15345"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p153code45"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">beginTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
try <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Essaye d'exécuter une ou plusieurs requêtes :</span>
    <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">...</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">...</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">...</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Si toutes ont réussi, valide les changements en une seule passe.</span>
    <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Si une des requête s'est mal déroulée, alors nous voulons annuler les changements</span>
    <span style="color: #666666; font-style: italic;">// de toutes les requêtes faisant partie de la transaction, même celles qui se sont</span>
    <span style="color: #666666; font-style: italic;">// bien déroulées. Tous les changements sont annulés d'un seul coup</span>
    <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rollBack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</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: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>Transactions dans en MVC avec Zend Framework</strong><br />
Imaginons que nous avons des produits divers. Ceux-ci sont enregistrer dans une la base de données.<br />
Les informations communes à tous les produits sont enregistrées dans la table Produit et toutes les données spécifiques à chaque type de produit dans la table correspondant au type : ProduitNomDuType. </p>
<p>Nous aurons donc les modèles Produit qui est une classe qui héritera de Zend_Db_Table_Abstract et Produit_Row qui héritera de Zend_Db_Table_Row_Abstract (nous aurons la même chose pour gérer les tables et ligne des ProduitNomDuType).</p>
<p>Pour ajouter un produit du type Foo nous allons donc devoir remplir la table &laquo;&nbsp;générique&nbsp;&raquo; Produit et ProduitFoo.<br />
Nous allons donc créer une transaction qui effectuera l&#8217;insertion des données dans les 2 tables.</p>
<p>Ce qui pourrait nous donner dans l&#8217;action ajouterAction() de notre controller quelque chose comme :</p>

<div class="wp_codebox"><table><tr id="p15346"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code" id="p153code46"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// ...</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// On récupère l'adaptater que nous avons sauvé dans le registry dans le boostrap</span>
<span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'db'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
&nbsp;
<span style="color: #666666; font-style: italic;">// On démarre la transaction</span>
<span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">beginTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
try <span style="color: #009900;">&#123;</span>
	Zend_Loader<span style="color: #339933;">::</span><span style="color: #004000;">loadClass</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Produit'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	Zend_Loader<span style="color: #339933;">::</span><span style="color: #004000;">loadClass</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ProduitFoo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$produitDb</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Produit<span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$produitDb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dataProduit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// $dataProduit est un tableau qui représente les données générique du produit</span>
&nbsp;
	<span style="color: #000088;">$produitFooDb</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ProduitFoo<span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$produitFooDb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dataProduitFoo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// $dataProduitFoo est un tableau qui représente les données spécifique du produit foo</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// On valide l'ensemble des requêtes</span>
	<span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Si une exception a été levée, on annule toutes les opérations du lot</span>
	<span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rollBack</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;">//...</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Cette transaction permettra par exemple de ne pas se retrouver avec juste les infos génériques du produit si l&#8217;ajout des infos dans ProduitFoo a levé une exception.</p>
<p><strong>Quelques liens utiles</strong></p>
<ul>
<li><a href="http://framework.zend.com/manual/fr/">Manuel de Zend Framework</a> : <a href="http://framework.zend.com/manual/fr/zend.db.html">Zend_Db</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.0/fr/index.html">Manuel de MySql 5</a></li>
<li><a href="http://www.developpez.com/">Developpez.com</a> : <a href="http://mysql.developpez.com/">MySQL</a> et <a href="http://zend-framework.developpez.com/">Zend Framework</a></li>
<li><a href="http://www.z-f.fr/">Communauté Francophone de Zend Framework</a></li>
</ul>
<p>N&#8217;hésitez pas à poser vos questions ou remarques dans les commentaires, je me ferais un plaisir d&#8217;y répondre.</p>
<p><em>Note: je ne me suis pas étendu sur le fonctionnement du MVC avec Zend Framework vu qu&#8217;il y a énormément de chose à dire et que cela fera partie d&#8217;un futur tutorial.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webinside.be/transactions-dans-sgbd-a-laide-de-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grande décision&#8230;</title>
		<link>http://www.webinside.be/grande-decision/</link>
		<comments>http://www.webinside.be/grande-decision/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 21:07:45 +0000</pubDate>
		<dc:creator>Hervé</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Programmation]]></category>

		<guid isPermaLink="false">http://www.webinside.be/?p=151</guid>
		<description><![CDATA[Après une longue absence et des postes pas très réguliers, j&#8217;ai décidé de recommencer à bloguer sérieusement. Nouveau concept J&#8217;ai également choisi de vous faire partager quelques concepts et expériences de programmation. Je posterais donc de temps en temps des tutoriaux. Je viens d&#8217;ailleurs d&#8217;installer les plugins wp-syntax et wp-codebox (je n&#8217;ai pas encore réellement [...]]]></description>
			<content:encoded><![CDATA[<p>Après une longue absence et des postes pas très réguliers, j&#8217;ai décidé de <del datetime="2008-07-10T20:42:58+00:00">re</del>commencer à bloguer sérieusement.</p>
<p><strong>Nouveau concept</strong><br />
J&#8217;ai également choisi de vous faire partager quelques concepts et expériences de programmation.<br />
Je posterais donc de temps en temps des tutoriaux.</p>
<p>Je viens d&#8217;ailleurs d&#8217;installer les plugins <a href="http://wordpress.org/extend/plugins/wp-syntax/">wp-syntax</a> et <a href="http://wordpress.org/extend/plugins/wp-codebox/">wp-codebox</a> (je n&#8217;ai pas encore réellement choisi celui que j&#8217;allais utiliser) à cet effet.</p>
<p>Ces plugins permettent la coloration de syntaxe de code source.<br />
Ce qui donne ceci :</p>

<div class="wp_codebox"><table><tr id="p15148"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p151code48"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d-m-Y'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Hello World ! '</span><span style="color: #339933;">.</span><span style="color: #000088;">$date</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Les divers tutos que j&#8217;aborderais seront axés sur des thèmes tels que :</p>
<ul>
<li><strong>Linux</strong> : config serveur</li>
<li><strong>Programmation Web</strong> : php5</li>
<li><strong>SGBD</strong>: mysql 5</li>
<li> &#8230;</li>
</ul>
<p>En espérant que cette nouvelle approche vous plaira, je vais réfléchir à mon premier tutorial&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webinside.be/grande-decision/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
