<?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>D-Sites</title>
	<atom:link href="http://www.d-sites.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.d-sites.com</link>
	<description>Web, PHP, Python, …</description>
	<lastBuildDate>Tue, 03 Jan 2012 08:39:55 +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>Symfony2: nom de la route depuis un template Twig</title>
		<link>http://www.d-sites.com/2011/12/08/symfony2-nom-de-la-route-depuis-un-template-twig/</link>
		<comments>http://www.d-sites.com/2011/12/08/symfony2-nom-de-la-route-depuis-un-template-twig/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 21:26:55 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony2]]></category>
		<category><![CDATA[global]]></category>
		<category><![CDATA[request]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[symfony2]]></category>
		<category><![CDATA[twig]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=1005</guid>
		<description><![CDATA[Dans Symfony2, il est possible d’accéder aux propriétés de la requête actuelle à partir d&#8217;un template Twig grâce aux variables globales. En l’occurrence, ça peut être utile pour connaître le nom de la route utilisée. Ainsi, avec la variable app.request, &#8230; <a href="http://www.d-sites.com/2011/12/08/symfony2-nom-de-la-route-depuis-un-template-twig/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Dans Symfony2, il est possible d’accéder aux propriétés de la requête actuelle à partir d&#8217;un template Twig grâce aux <a href="http://nerdpress.org/2011/09/12/symfony-2-twig-global-variables/">variables globales</a>.</p>
<p>En l’occurrence, ça peut être utile pour connaître le nom de la route utilisée. Ainsi, avec la variable <code>app.request</code>, on peut avoir accès aux <em>attributes</em>, et donc à la route utilisée. En PHP, on aurions pu récupérer l&#8217;information comme ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributes</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_route'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Avec Twig, le code deviens ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="twig" style="font-family:monospace;">{{ app.request.attributes.get('_route') }}</pre></div></div>

<p>Une fonctionnalité toute bête mais qui peut s&#8217;avérer très pratique!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/12/08/symfony2-nom-de-la-route-depuis-un-template-twig/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony 2 et PostgreSQL: Mots réservés</title>
		<link>http://www.d-sites.com/2011/12/03/symfony-2-et-postgresql-mots-reserves/</link>
		<comments>http://www.d-sites.com/2011/12/03/symfony-2-et-postgresql-mots-reserves/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 18:12:52 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Bases de données]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Symfony2]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=991</guid>
		<description><![CDATA[Symfony 2 propose une abstraction des entities très intéressante grâce à Doctrine. Je poste ce petit article car j&#8217;ai eu une erreur tout simple:  $ php app/console doctrine:schema:update --force Updating database schema... &#160; [PDOException] SQLSTATE[42601]: Syntax error: 7 ERREUR:  erreur &#8230; <a href="http://www.d-sites.com/2011/12/03/symfony-2-et-postgresql-mots-reserves/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Symfony 2 propose une abstraction des <em>entities</em> très intéressante grâce à Doctrine. Je poste ce petit article car j&#8217;ai eu une erreur tout simple:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"> $ php app/console doctrine:schema:update --force
Updating database schema...
&nbsp;
[PDOException] SQLSTATE[42601]: Syntax error: 7 ERREUR:  erreur de syntaxe sur ou près de « User » 
LINE 1: CREATE TABLE User (id INT NOT NULL, username VARCHAR(255) NO...              
                       ^          </pre></div></div>

<p>En fait, j&#8217;ai créé un <em>bundle</em> nommé <code>User</code>, et doctrine souhaite donc créer la table <code>User</code>. Le problème, c&#8217;est que <strong>user</strong> est un mot clé réservé dans PostgreSQL. Par conséquent, il faut donc forcer Doctrine à <em>escaper</em> le nom de la table. Pour se faire, il suffit d&#8217;ajouter une annotation <code>Table</code> en préfixant et suffixant le nom de la table par <code>`</code>.</p>
<p>Voici par exemple ma classe User <strong>avant</strong> la correction:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * @ORM\Entity
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> User <span style="color: #000000; font-weight: bold;">extends</span> BaseUser
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// ...</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Il suffit donc de d&#8217;ajouter l&#8217;annotation <code>@ORM\Table</code> en spécifiant le nom de la table entouré de <code>`</code>. Le nouveau code est:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * @ORM\Entity
 * @ORM\Table(name=&quot;`User`&quot;)
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> User <span style="color: #000000; font-weight: bold;">extends</span> BaseUser
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// ...</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ainsi, Doctrine va générer ses requêtes en ajoutant des caractères d&#8217;échappement sur le nom de la table. Ainsi, vous n&#8217;aurez plus d&#8217;erreur! <img src='http://www.d-sites.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/12/03/symfony-2-et-postgresql-mots-reserves/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Polygones de Thyssen: algorithme de Steven Forture en PHP</title>
		<link>http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/</link>
		<comments>http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 08:00:39 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Affichage]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[forture]]></category>
		<category><![CDATA[polygon]]></category>
		<category><![CDATA[thyssen]]></category>
		<category><![CDATA[voronoï]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=958</guid>
		<description><![CDATA[Pour des besoins professionnels, j&#8217;ai réécrit l&#8217;algorithme de Steven Fortune permettant d&#8217;obtenir un diagramme de Voronoï à partir de points connus, en transformant la librairie JavaScript de gorhill. Vous pouvez trouver les fichiers sources (en PHP 5) sur ce dépôt &#8230; <a href="http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Pour des besoins professionnels, j&#8217;ai réécrit l&#8217;algorithme de Steven Fortune permettant d&#8217;obtenir un diagramme de Voronoï à partir de points connus, en transformant la <a href="https://github.com/gorhill/Javascript-Voronoi">librairie JavaScript de <em>gorhill</em></a>.</p>
<p>Vous pouvez trouver les fichiers sources (en PHP 5) sur ce dépôt GitHub:</p>
<ul>
<li><a href="https://github.com/sroze/PHP-Voronoi-algorithm">https://github.com/sroze/PHP-Voronoi-algorithm</a></li>
</ul>
<h2>Exemple d&#8217;utilisation</h2>
<p>Voici un exemple d&#8217;utilisation, qui permet de générer un diagramme de Voronoï (ou autrement dit des polygones de Thyssen) à partir de points générés automatiquement:</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: #b1b100;">require_once</span> <span style="color: #0000ff;">'../library/Nurbs/Voronoi.php'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'../library/Nurbs/Point.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$bbox</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> stdClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bbox</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xl</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bbox</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xr</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bbox</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">yt</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bbox</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">yb</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$xo</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dx</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$yo</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dy</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$height</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$n</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sites</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</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;">// On créé l'image</span>
<span style="color: #000088;">$im</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$white</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$red</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$green</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$black</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">imagefill</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$white</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//imageantialias($im, true);</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// On créé des points aléatoires que l'on dessine</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$n</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$point</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Nurbs_Point<span style="color: #009900;">&#40;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xo</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dx</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$yo</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dy</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$sites</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$point</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">imagerectangle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$point</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$point</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$point</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$point</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$black</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$voronoi</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Voronoi<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$diagram</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$voronoi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">compute</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sites</span><span style="color: #339933;">,</span> <span style="color: #000088;">$bbox</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//var_dump($diagram);</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//var_dump('sites', $sites, 'diagram', $diagram, 'cells', $diagram['cells']);//, 'voronoi', $voronoi);</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;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diagram</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cells'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$cell</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// On va agreger les points du polygone.</span>
	<span style="color: #000088;">$points</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</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: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cell</span><span style="color: #339933;">-&gt;</span>_halfedges<span style="color: #009900;">&#41;</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: #000088;">$v</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cell</span><span style="color: #339933;">-&gt;</span>_halfedges<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStartPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$points</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$points</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</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;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span><span style="color: #339933;">.</span><span style="color: #0000ff;">': no start point'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cell</span><span style="color: #339933;">-&gt;</span>_halfedges<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;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$halfedge</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cell</span><span style="color: #339933;">-&gt;</span>_halfedges<span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$edge</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$halfedge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">edge</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">va</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">vb</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #990000;">imageline</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">va</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">va</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span><span style="color: #339933;">,</span> <span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">vb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">vb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span><span style="color: #339933;">,</span> <span style="color: #000088;">$red</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #000088;">$v</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$halfedge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getEndPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$points</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$points</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</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;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span><span style="color: #339933;">.</span><span style="color: #0000ff;">': no end point #'</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// On construit le polygone</span>
	<span style="color: #000088;">$color</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocatealpha</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">imagefilledpolygon</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$points</span><span style="color: #339933;">,</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$points</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$j</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// On affiche l'image</span>
<span style="color: #990000;">imagepng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'voronoi.png'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Voici un exemple d&#8217;image:<br />
<a href="http://www.d-sites.com/wp-content/uploads/2011/11/voronoi.png"><img src="http://www.d-sites.com/wp-content/uploads/2011/11/voronoi.png" alt="" title="voronoi" width="400" height="400" class="aligncenter size-full wp-image-975" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend PHP 5.3 Developer Certified</title>
		<link>http://www.d-sites.com/2011/11/25/zend-php-5-3-developer-certified/</link>
		<comments>http://www.d-sites.com/2011/11/25/zend-php-5-3-developer-certified/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 14:24:24 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Actualités]]></category>
		<category><![CDATA[D-Sites]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[5.3]]></category>
		<category><![CDATA[certification]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=984</guid>
		<description><![CDATA[Ça y est, je suis développeur PHP 5.3 certifié par Zend! Le principe du concours est très simple: vous avez 90 minutes pour répondre à 70 questions aléatoires concernant le fonctionnement de PHP ainsi que les différents domaines qui l&#8217;entour, &#8230; <a href="http://www.d-sites.com/2011/11/25/zend-php-5-3-developer-certified/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ça y est, je suis développeur PHP 5.3 certifié par Zend! <img src='http://www.d-sites.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://www.d-sites.com/wp-content/uploads/2011/11/zce-php5-3-logo.gif"><img class="aligncenter size-full wp-image-985" title="zce-php5-3-logo" src="http://www.d-sites.com/wp-content/uploads/2011/11/zce-php5-3-logo.gif" alt="" width="73" height="68" /></a>Le principe du concours est très simple: vous avez 90 minutes pour répondre à 70 questions aléatoires concernant le fonctionnement de PHP ainsi que les différents domaines qui l&#8217;entour, à savoir le SQL, la sécurité en général, etc&#8230;</p>
<p>Je vous conseil de le passer, c&#8217;est sans aucun doutes un bon élément sur le CV. Si vous avez un quelconque question, n&#8217;hésitez pas!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/11/25/zend-php-5-3-developer-certified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Un rapport par défaut dans Trac</title>
		<link>http://www.d-sites.com/2011/11/21/un-rapport-par-defaut-dans-trac/</link>
		<comments>http://www.d-sites.com/2011/11/21/un-rapport-par-defaut-dans-trac/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 09:29:36 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Conception]]></category>
		<category><![CDATA[Production]]></category>
		<category><![CDATA[default]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=972</guid>
		<description><![CDATA[Dans Trac, lorsque l&#8217;on clique sur &#8220;Voir les tickets&#8221;, on arrive sur la liste des différents rapports disponibles. Pour des questions pratiques, je préférais arriver directement sur la page du rapport des tickets actifs. On peut donc modifier les liens &#8230; <a href="http://www.d-sites.com/2011/11/21/un-rapport-par-defaut-dans-trac/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Dans <a href="http://trac.edgewall.org/">Trac</a>, lorsque l&#8217;on clique sur &#8220;Voir les tickets&#8221;, on arrive sur la liste des différents rapports disponibles.</p>
<p>Pour des questions pratiques, je préférais arriver directement sur la page du rapport des tickets actifs. On peut donc modifier les liens du menu horizontal pour y arriver! Modifiez donc le fichier <code>trac.ini</code> comme ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>mainnav<span style="">&#93;</span></span>
tickets.href <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> /report/1</span></pre></div></div>

<p>Ainsi, ce sera le rapport d&#8217;ID <code>1</code> qui sera ouvert.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/11/21/un-rapport-par-defaut-dans-trac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crypter un mot de passe comme dans /etc/shadow</title>
		<link>http://www.d-sites.com/2011/10/15/crypter-un-mot-de-passe-comme-dans-etcshadow/</link>
		<comments>http://www.d-sites.com/2011/10/15/crypter-un-mot-de-passe-comme-dans-etcshadow/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 09:42:25 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Adm. Système]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[crypt]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[salt]]></category>
		<category><![CDATA[sha]]></category>
		<category><![CDATA[shadow]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=970</guid>
		<description><![CDATA[Petit test pour crypter un mot de passe comme dans le fichier /etc/shadow avec Python! Vous pouvez crypter une chaîne de caractères en utilisant le même SALT, à savoir la clé de cryptage. Dans une chaine du fichier /etc/shadow, voici &#8230; <a href="http://www.d-sites.com/2011/10/15/crypter-un-mot-de-passe-comme-dans-etcshadow/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Petit test pour crypter un mot de passe comme dans le fichier <code>/etc/shadow</code> avec Python! Vous pouvez crypter une chaîne de caractères en utilisant le même <em>SALT</em>, à savoir la clé de cryptage.</p>
<p>Dans une chaine du fichier <code>/etc/shadow</code>, voici un exemple de ligne:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sroze:$6$jWp7fotG$ikvxu3kvwbn36XvznP1FHnokYpY/MScI6QjYz.vJJ1r/klF2Nwiv3lkuSvs8hz4fZ08v7OAANFKfOaotPsjL50:15224:0:99999:7:::</pre></div></div>

<p>Ici, on peut voir que mon mot de passe personnel est <code>$6$jWp7fotG$ikvxu3kvwbn36XvznP1FHnokYpY/MScI6QjYz.vJJ1r/klF2Nwiv3lkuSvs8hz4fZ08v7OAANFKfOaotPsjL50</code>. Cette chaine signifie que l&#8217;encodage utilisé est le numéro 6 (<code>$6$</code>) à savoir le SHA-2, le <em>SALT</em> est <code>jWp7fotG</code>. Vous pouvez retrouver plus d&#8217;informations à ce sujet <a href="http://en.wikipedia.org/wiki/Crypt_%28Unix%29">ici</a>.</p>
<p>En utilisant la même clé, on peut donc retrouver le mot de passe, comme ceci!</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"># python -c &quot;import crypt, getpass, pwd; print crypt.crypt('-PASSWORD-', '\$6\$jWp7fotG\$')&quot;
$6$jWp7fotG$ikvxu3kvwbn36XvznP1FHnokYpY/MScI6QjYz.vJJ1r/klF2Nwiv3lkuSvs8hz4fZ08v7OAANFKfOaotPsjL50</pre></div></div>

<p>On vérifie la correspondance:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"># cat /etc/shadow | grep sroze | cut -d&quot;:&quot; -f2
$6$jWp7fotG$ikvxu3kvwbn36XvznP1FHnokYpY/MScI6QjYz.vJJ1r/klF2Nwiv3lkuSvs8hz4fZ08v7OAANFKfOaotPsjL50</pre></div></div>

<p> <img src='http://www.d-sites.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/10/15/crypter-un-mot-de-passe-comme-dans-etcshadow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C: Régler le problème des defunct process</title>
		<link>http://www.d-sites.com/2011/07/05/c-regler-le-probleme-des-defunct-process/</link>
		<comments>http://www.d-sites.com/2011/07/05/c-regler-le-probleme-des-defunct-process/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 21:08:05 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Adm. Système]]></category>
		<category><![CDATA[Conception]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[MyOnlineSSH]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[defunct]]></category>
		<category><![CDATA[fork]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=963</guid>
		<description><![CDATA[Lorsque vous développez une application, il est parfois très intéressant d&#8217;utiliser des threads ou plusieurs processus pour exécuter plusieurs tâches simultanément. Nous allons ici voir un problème qui arrive lors que l&#8217;on utilise plusieurs processus, via un fork(). En effet, &#8230; <a href="http://www.d-sites.com/2011/07/05/c-regler-le-probleme-des-defunct-process/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Lorsque vous développez une application, il est parfois très intéressant d&#8217;utiliser des threads ou plusieurs processus pour exécuter plusieurs tâches simultanément. Nous allons ici voir un problème qui arrive lors que l&#8217;on utilise plusieurs processus, via un <code>fork()</code>. En effet, en <code>C</code>, la fonction <strong>fork</strong> permet de créer un nouveau processus, qui devient fils du processus appelant le fork.</p>
<h2>Processus zombies (<em>defunct</em>)</h2>
<p>Par défaut, lorsque le processus père s&#8217;arrête, tous les processus fils s&#8217;arrête. À l&#8217;inverse, lorsqu&#8217;un processus fils s&#8217;arrête &#8211; via un <code>exit(0);</code> par exemple -, sa mémoire est libérée, il devient un processus zombie (seul le bloc de contrôle reste présent) et le processus père continue de fonctionner.</p>
<p>Ainsi, l&#8217;on peut voir de nombreuses lignes marquées par un <em>defunct</em> lorsque l&#8217;on liste les processus avec un <code>ps</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">root      9175  0.0  0.0 136380  1100 ?        Sl   Jun30   0:00 /[...]/relay
root      9629  0.0  0.0      0     0 ?        Z    Jun23   0:00 [relay] &lt;defunct&gt;
root      9853  0.0  0.0      0     0 ?        Z    Jun30   0:00 [relay] &lt;defunct&gt;
root      9884  0.0  0.0      0     0 ?        Z    Jun30   0:00 [relay] &lt;defunct&gt;</pre></div></div>

<p>C&#8217;est parce que le processus père n&#8217;écoutes pas le signal <strong>SIGCHLD</strong>, qui est envoyé par le fils lors de son extinction. Ainsi, en écoutant le signal, le père peut libérer son bloc de contrôle. En <code>C</code>, c&#8217;est la fonction <code><strong>waitpid</strong></code> qui nous sera utile.</p>
<h2>Une ligne à ajouter</h2>
<p>Il n&#8217;y a qu&#8217;une seule ligne (ainsi qu&#8217;un <code>#include</code>) à ajouter à votre code <code>C</code> pour que les processus zombies soient &#8220;ramassés&#8221; par votre processus père. De temps en temps &#8211; l&#8217;idéal étant la boucle principale s&#8217;il y a -, exécutée cette ligne ci:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>waitpid<span style="color: #009900;">&#40;</span>WAIT_ANY<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> WNOHANG<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Les arguments sont les suivants:</p>
<ul>
<li><code>WAIT_ANY</code> est la constante permettant de dire que l&#8217;on souhaite attendre n&#8217;importe quel des processus fils de ce processus. À la place, nous aurions pu mettre le <em>pid</em> d&#8217;un processus particulier.</li>
<li><code>NULL</code> permet de ne pas récupérer d&#8217;informations de statut du processus.</li>
<li><code>WNOHANG</code> est une option permettant d&#8217;exécuter <code>waitpid</code> en mode <strong>non-bloquant</strong>.</li>
</ul>
<p>N&#8217;oubliez pas d&#8217;inclure l&#8217;en-tête des fonctions et constantes ainsi:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;sys/wait.h&gt;</span></pre></div></div>

<p>Ainsi, il ne restera plus de processus zombie, ou <em>defunct</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/07/05/c-regler-le-probleme-des-defunct-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Varnish en reverse-proxy: le problème des adresses locales</title>
		<link>http://www.d-sites.com/2011/06/10/varnish-en-reverse-proxy-le-probleme-des-adresses-locales/</link>
		<comments>http://www.d-sites.com/2011/06/10/varnish-en-reverse-proxy-le-probleme-des-adresses-locales/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 10:10:32 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Adm. Système]]></category>
		<category><![CDATA[Conception]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[reverse]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[varnish]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[x-forwarded-for]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=959</guid>
		<description><![CDATA[Si vous utilisez nginx ou Apache derrière Varnish, vous aurez remarqué que l&#8217;adresse IP du client récupérée est l&#8217;adresse locale (ou bien l&#8217;adresse du serveur hébergeant Varnish). Cela est le cas parce-que c&#8217;est Varnish qui créé la connexion TCP à &#8230; <a href="http://www.d-sites.com/2011/06/10/varnish-en-reverse-proxy-le-probleme-des-adresses-locales/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Si vous utilisez nginx ou Apache derrière Varnish, vous aurez remarqué que l&#8217;adresse IP du client récupérée est l&#8217;adresse locale (ou bien l&#8217;adresse du serveur hébergeant Varnish). Cela est le cas parce-que c&#8217;est Varnish qui créé la connexion TCP à nginx/apache, et non le client directement. Pour cela, nous allons tout simplement installer un module sur votre serveur Web, pour qui va utiliser une en-tête (<code>X-Forwarded-For</code>) pour connaitre l&#8217;IP du client.</p>
<h2>Pour nginx</h2>
<p>Il nous faut nginx compilé avec le module <strong>Real-IP</strong> (<code>--with-http_realip_module</code>), ce qui est le cas par défaut dans les paquets CentOS et Debian. Dans le fichier de configuration <code>/etc/nginx/nginx.conf</code>, dans la catégorie <code>http {...}</code>, ajoutez ça:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">    set_real_ip_from 127.0.0.1;
    real_ip_header X-Forwarded-For;</pre></div></div>

<p>Redémarrez le serveur nginx, et c&#8217;est bon.</p>
<h2>Pour Apache</h2>
<p>Pour Apache, il faut installer le module <strong>RPAF2</strong>. Je vous invite à lire l&#8217;article très intéressant de <a href="http://wiki.tyk.nu/index.php/Using_Varnish_to_protect_Apache_against_slowloris#Fixing_the_Apache_client_IP_problem_with_mod_rpaf2_.28recommended.29">wiki.tyk.nu</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/06/10/varnish-en-reverse-proxy-le-probleme-des-adresses-locales/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tunnel SSH sur le port 80, utilisant le reverse proxy Varnish</title>
		<link>http://www.d-sites.com/2011/06/09/tunnel-ssh-sur-le-port-80-utilisant-le-reverse-proxy-varnish/</link>
		<comments>http://www.d-sites.com/2011/06/09/tunnel-ssh-sur-le-port-80-utilisant-le-reverse-proxy-varnish/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 09:26:08 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Adm. Système]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[httptunnel]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[reverse]]></category>
		<category><![CDATA[varnish]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=951</guid>
		<description><![CDATA[Dans un article précédent, nous avons vu comment créer une connexion SSH à travers un tunnel HTTP, mais le problème est que vous ne pouviez pas utiliser le port 80 si votre serveur hébergeait un serveur HTTP! Nous allons maintenant &#8230; <a href="http://www.d-sites.com/2011/06/09/tunnel-ssh-sur-le-port-80-utilisant-le-reverse-proxy-varnish/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Dans un article précédent, nous avons vu comment <a href="http://www.d-sites.com/2011/01/18/tunnel-http-sur-ssh-connexion-securisee-et-non-filtree/">créer une connexion SSH à travers un tunnel HTTP</a>, mais le problème est que vous ne pouviez pas utiliser le port 80 si votre serveur hébergeait un serveur HTTP! Nous allons maintenant voir comment mettre en place Varnish, l&#8217;un des meilleurs reverse-proxy (qui peut également servir de système de cache), pour utiliser à la fois <code>httptunnel</code> et votre serveur Web.</p>
<h2>Mise en place de Varnish</h2>
<p>Nous allons commencer par mettre en place Varnish de la façon suivante:</p>
<p style="text-align: center;"><a href="http://www.d-sites.com/wp-content/uploads/2011/06/Varnish-HTTPTunnel.png"><img class="aligncenter size-full wp-image-952" title="Varnish-HTTPTunnel" src="http://www.d-sites.com/wp-content/uploads/2011/06/Varnish-HTTPTunnel.png" alt="" width="478" height="225" /></a></p>
<p>Pour cela, nous allons installer <strong>varnish</strong> depuis les dépôts. Pour CentOS:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"># yum install varnish</pre></div></div>

<p>Pour commencer, nous allons modifier le fichier de configuration de Varnish, afin de configurer les différents <em>backends</em>. Nous supposer ceci:
<ul>
<li>Votre serveur Web écoute sur le <strong>port 8001</strong></li>
<li>Le serveur <code>hts</code> écoute sur le <strong>port 8002</strong><br /><strong>Note:</strong> vous pourrez modifier la configuration de votre serveur Web à la fin, si vous souhaitez avoir un minimum de downtime.</li>
</ul>
<p><span id="more-951"></span>Modifiez donc le fichier <code>/etc/varnish/default.vcl</code>, et, dans notre exemple, voici la configuration:</p>

<div class="wp_syntax"><div class="code"><pre class="vcl" style="font-family:monospace;"># Backend par défault: nginx
# Prend en charge les requetes statiques et dynamiques avec PHP
backend nginx {
  .host = &quot;127.0.0.1&quot;;
  .port = &quot;8001&quot;;
  .first_byte_timeout = 600s;
}
&nbsp;
# Backend HTTPTunnel: tunnel HTTP
backend hts {
  .host = &quot;127.0.0.1&quot;;
  .port = &quot;8002&quot;;
  .first_byte_timeout = 600s;
}
&nbsp;
# Lors de la réception d'une requête, on choisi le backend en fonction
# de l'HOST.
sub vcl_recv {
        if (req.http.host ~ &quot;tunnel.example.com&quot;) {
                set req.backend = hts;
                return(pipe);
        } else {
                set req.backend = nginx;
        }
}</pre></div></div>

<p>Avec cette configuration, Varnish va regarder les paquets et si le nom d&#8217;hôte contient &#8220;tunnel.example.com&#8221;, il redirige la requête vers le backend <strong>hts</strong>, sinon vers le backend <strong>nginx</strong>.</p>
<h2>Démarrage automatique de Varnish</h2>
<p>Pour que Varnish démarre automatiquement et qu&#8217;il utilise le port 80, nous allons utiliser le script de démarrage fourni, et nous allons configurer l&#8217;initialisation de Varnish dans le fichier <code>/etc/sysconfig/varnish</code>. Dans ce fichier, modifiez le paramètre <code>DAEMON_OPTS</code>, comme ceci, par exemple:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">DAEMON_OPTS=&quot;-a :80 \
             -T localhost:8100 \
             -f /etc/varnish/default.vcl \
             -u varnish -g varnish \
             -S /etc/varnish/secret \
             -s file,/var/lib/varnish/varnish_storage.bin,1G&quot;</pre></div></div>

<p>Ceci va permettre de démarrer Varnish pour qu&#8217;il écoute le port 80, sur toutes les interfaces, que l&#8217;administration Web soit accessible en local sur le port 8100, qu&#8217;il démarre en tant qu&#8217;utilisateur et groupe varnish, et qu&#8217;il puisse utiliser un fichier de 1G pour gérer son cache.</p>
<p>Configurez votre serveur Web pour utiliser les bons ports, démarrez hts, et varnish, comme ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"># service varnish start</pre></div></div>

<h2>Utilisation de HTTPTunnel avec le reverse proxy Varnish</h2>
<p>Ensuite, vous pouvez utiliser HTTPTunnel comme ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ htc --forward-port 8081 tunnel.example.com:80
$ ssh root@localhost -p 8081</pre></div></div>

<p>Et c&#8217;est parti, vous utilisez votre tunnel HTTP sur le port 80, en même temps que votre serveur Web!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/06/09/tunnel-ssh-sur-le-port-80-utilisant-le-reverse-proxy-varnish/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Piwik: des statistiques Web à la Google Analitycs</title>
		<link>http://www.d-sites.com/2011/04/01/piwik-des-statistiques-web-a-la-google-analitycs/</link>
		<comments>http://www.d-sites.com/2011/04/01/piwik-des-statistiques-web-a-la-google-analitycs/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 10:00:17 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[piwik]]></category>
		<category><![CDATA[statistics]]></category>
		<category><![CDATA[stats]]></category>
		<category><![CDATA[visitors]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=866</guid>
		<description><![CDATA[Google Analytics est le service gratuit (pour un usage modéré, mais relativement important) de Google permettant d&#8217;obtenir des statistiques très complètes sur les visiteurs ainsi que leurs comportements sur vos sites Web. Il peut également être comparé à Xiti, qui &#8230; <a href="http://www.d-sites.com/2011/04/01/piwik-des-statistiques-web-a-la-google-analitycs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.google.com/analytics/">Google Analytics</a> est le service gratuit (pour un usage modéré, mais relativement important) de Google permettant d&#8217;obtenir des statistiques très complètes sur les visiteurs ainsi que leurs comportements sur vos sites Web. Il peut également être comparé à <a href="http://en.atinternet.com/Products/XiTi-Solutions.aspx#XitiFree">Xiti</a>, qui était l&#8217;un des premiers services gratuits de statistiques. Le principe est très simple: vous collez un bout de code JavaScript qui appelle une page Web sur le serveur de Google, Xiti ou autre suivant le service que vous utilisez. Ensuite, vous pouvez visualiser les statistiques de vos sites depuis une interface fort sympathique.</p>
<div id="attachment_931" class="wp-caption alignleft" style="width: 220px"><a href="http://www.d-sites.com/wp-content/uploads/2011/03/google-analytics-dashboard1.jpg"><img class="size-medium wp-image-931 " title="google-analytics-dashboard1" src="http://www.d-sites.com/wp-content/uploads/2011/03/google-analytics-dashboard1-300x279.jpg" alt="Google Analytics" width="210" height="195" /></a><p class="wp-caption-text">Aperçu de Google Analytics</p></div>
<div id="attachment_932" class="wp-caption alignright" style="width: 220px"><a href="http://www.d-sites.com/wp-content/uploads/2011/03/070729_xiti.jpg"><img class="size-medium wp-image-932 " title="070729_xiti" src="http://www.d-sites.com/wp-content/uploads/2011/03/070729_xiti-300x239.jpg" alt="" width="210" height="167" /></a><p class="wp-caption-text">Aperçu de Xiti</p></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>Deux gros problèmes</h2>
<p>À mes yeux, il y a deux gros problèmes</p>
<ul>
<li>Le premier, est que toutes vos données sont stockées chez un prestataire qui n&#8217;a aucune garantie si vous ne payez pas un &#8220;abonnement&#8221; à leurs services.</li>
<li>Le second et le plus important, c&#8217;est que la vitesse de votre site Web dépend de la vitesse de leurs services: les statistiques étant propulsées par un script JavaScript, le navigateur de votre visiteur va attendre que ce script soit chargé avant de continuer à charger le reste de la page et de terminer le rendu. Ainsi, si le script met 100ms à se charger, dans une bonne partie des cas, l&#8217;affichage du côté visiteur sera retardé d&#8217;environ 100ms, ce qui n&#8217;est pas négligeable!</li>
</ul>
<p>Par conséquent, il peut être très intéressant de trouver une alternative (open-source de préférence) pour stocker et gérer vous même vos statistiques, le plus simplement possible, de préférence. Le projet le plus abouti est <strong>Piwik</strong>.</p>
<h2>Une alternative très intéressante</h2>
<p><a href="http://fr.piwik.org">Piwik</a> est une application open-source développée en PHP qui fourni tout l&#8217;arsenal pour obtenir des statistiques aussi intéressantes que Google Analitycs!</p>
<div id="attachment_936" class="wp-caption alignleft" style="width: 160px"><a href="http://www.d-sites.com/wp-content/uploads/2011/03/piwik-dashboard.png"><img class="size-thumbnail wp-image-936" title="piwik-dashboard" src="http://www.d-sites.com/wp-content/uploads/2011/03/piwik-dashboard-150x150.png" alt="" width="150" height="150" /></a><p class="wp-caption-text">Tableau de bord de Piwik</p></div>
<div id="attachment_937" class="wp-caption alignright" style="width: 160px"><a href="http://www.d-sites.com/wp-content/uploads/2011/03/piwik-visiteurs.png"><img class="size-thumbnail wp-image-937" title="piwik-visiteurs" src="http://www.d-sites.com/wp-content/uploads/2011/03/piwik-visiteurs-150x150.png" alt="" width="150" height="150" /></a><p class="wp-caption-text">Récapitulatif visites de Piwik</p></div>
<p>&nbsp;</p>
<p>Pour installer Piwik, il vous suffit de télécharger le code PHP, de le mettre en place sur votre serveur Web, de suivre le processus d&#8217;installation très bien expliqué, et c&#8217;est partit!</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ wget http://piwik.org/latest.zip
$ unzip latest.zip
$ cp -R piwik /home/www/your.domain.example.com/htdocs/
$ chgrp -R www /home/www/your.domain.example.com/htdocs/piwik/
$ chmod g+w /home/www/your.domain.example.com/htdocs/piwik/</pre></div></div>

<p><strong>Note:</strong> Vous pouvez également retrouver le <a href="http://piwik.org/docs/installation/">processus d&#8217;installation plus détaillé</a> sur le site Web de Piwik.</p>
<p>C&#8217;est donc tout naturellement que j&#8217;ai choisi Piwik pour récupérer des statistiques de mes sites Web.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/04/01/piwik-des-statistiques-web-a-la-google-analitycs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using apc
Database Caching using apc
Object Caching 781/916 objects using apc

Served from: d-sites.com @ 2012-02-04 18:19:54 -->
