<?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>Même pas mal! &#187; php</title>
	<atom:link href="http://www.memepasmal.ch/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.memepasmal.ch</link>
	<description>La vie à Genève et aux alentours</description>
	<lastBuildDate>Sat, 11 Feb 2012 15:32:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Afficher un array PHP en treeview</title>
		<link>http://www.memepasmal.ch/2011/05/10/php-array-treeview/</link>
		<comments>http://www.memepasmal.ch/2011/05/10/php-array-treeview/#comments</comments>
		<pubDate>Tue, 10 May 2011 14:09:19 +0000</pubDate>
		<dc:creator>gael</dc:creator>
				<category><![CDATA[Foutoir technologique]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.memepasmal.ch/?p=2136</guid>
		<description><![CDATA[Si tu lis ceci c&#8217;est que le titre ne t&#8217;a pas découragé, bravo! Aujourd&#8217;hui donc, un article qui va te piquer les yeux. Ayant récemment eu besoin (en PHP) d&#8217;afficher le contenu d&#8217;une variable tableau sous forme de treeview, je me suis rendu compte que les bouts de code permettant une telle opération étaient plus [...]]]></description>
			<content:encoded><![CDATA[Si tu lis ceci c&#8217;est que le titre ne t&#8217;a pas découragé, bravo!<br />
<br />
Aujourd&#8217;hui donc, un article qui va te piquer les yeux.<br />
<br />
Ayant récemment eu besoin (en PHP) d&#8217;afficher le contenu d&#8217;une variable tableau sous forme de <em>treeview</em>, je me suis rendu compte que les bouts de code permettant une telle opération étaient plus que rares sur la toile, et que ceux disponibles étaient compliqués voire complètement pourris. Tu noteras que je tiens en très haute estime certains de mes compatriotes développeurs.<br />
<br />
N&#8217;étant jamais mieux servi que par soi-même je me suis lancé dans le codage d&#8217;une fonction récursive, le résultat s&#8217;est avéré être beaucoup plus simple que prévu.<br />
<br />
Bref, voici le code miraculeux fait maison, basique et efficace, parce que c&#8217;est tout ce qu&#8217;on lui demande.<br />
<br />
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:200px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// Fonction de dessin basique d'un &quot;array&quot; PHP sous forme de treeview</span><br />
<span style="color: #666666; font-style: italic;">// 10.05.2011 - gael@memepasmal.ch - http://www.memepasmal.ch/2011/05/10/php-array-treeview/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> drawTree<span style="color: #009900;">&#40;</span><span style="color: #000088;">$myarray</span><span style="color: #339933;">,</span> <span style="color: #000088;">$level</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Boucle sur chaque élément du tableau</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myarray</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// En cas d'objet on convertit en tableau</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span><span style="color: #000088;">$value</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Si l'élément est un tableau</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// On l'affiche en tant que noeud</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div style=&quot;padding-left: '</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$level</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'px&quot;&gt;['</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">']&lt;/div&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Puis on affiche son arborescence, à un niveau supérieur</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drawTree<span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$level</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// C'est une valeur, on l'affiche</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div style=&quot;padding-left: '</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$level</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'px&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' = &lt;b&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$value</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/b&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div><br />
<br />
Tu copies ça quelque part dans ton code PHP, tu appelles la fonction &laquo;&nbsp;<em>drawTree</em>&nbsp;&raquo; en passant ta variable <em>array</em> en paramètre, et puis tu admires le splendide résultat en sirotant ta bière.<br />
<br />
Merci de ton attention, tu peux maintenant reprendre une vie normale.]]></content:encoded>
			<wfw:commentRss>http://www.memepasmal.ch/2011/05/10/php-array-treeview/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>Oui mais pas toujours</title>
		<link>http://www.memepasmal.ch/2010/12/24/oui-mais-pas-toujours/</link>
		<comments>http://www.memepasmal.ch/2010/12/24/oui-mais-pas-toujours/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 09:23:57 +0000</pubDate>
		<dc:creator>gael</dc:creator>
				<category><![CDATA[Foutoir technologique]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.memepasmal.ch/?p=1993</guid>
		<description><![CDATA[Grâce à mes conseils technologiques de la veille tu pouvais faire tomber la magie enneigée de nouyelle sur ton blog, je vais aujourd&#8217;hui te montrer comment améliorer cette féerie ambiante. Le problème du tutoriel d&#8217;hier est qu&#8217;il te faut modifier ton fichier &#171;&#160;header.php&#160;&#187; pour y inclure le code JavaScript chaque début décembre et le re-modifier [...]]]></description>
			<content:encoded><![CDATA[Grâce à mes <a href="/2010/12/23/que-tombe-la-neige/">conseils technologiques de la veille</a> tu pouvais faire tomber la magie enneigée de nouyelle sur ton blog, je vais aujourd&#8217;hui te montrer comment améliorer cette féerie ambiante.<br />
<br />
Le problème du tutoriel d&#8217;hier est qu&#8217;il te faut modifier ton fichier &laquo;&nbsp;<em>header.php</em>&nbsp;&raquo; pour y inclure le code JavaScript chaque début décembre et le re-modifier à la fin de l&#8217;hiver pour retirer le script, au risque de voir tomber des flocons sur ton blog en plein mois d&#8217;août. On n&#8217;a pas tous la patience nécessaire de l&#8217;exercice, et demander des modifications à son webmaster trop souvent risque fort de finir par l&#8217;énerver profondément.<br />
<br />
Voici donc un petit bout de code PHP fait maison qui permet de limiter <del datetime="2010-12-23T18:07:44+00:00">magiquement</del> automatiquement l&#8217;exécution du script des flocons entre décembre et janvier compris.<br />
<br />
Dans ton fichier &laquo;&nbsp;<em>header.php</em>&nbsp;&raquo; tu remplaces donc la ligne que je t&#8217;ai suggérée hier.<br />
<br />
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/snowstorm.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></div></td></tr></tbody></table></div><br />
<br />
Par celles-ci.<br />
<br />
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Limite l'intégration du script de tempête de neige entre décembre et janvier compris</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot; src=&quot;/snowstorm.js&quot;&gt;&lt;/script&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div><br />
<br />
Et ainsi, chaque année cette saleté de magie s&#8217;opérera toute seule.<br />
<br />
J&#8217;en profite pour te souhaiter un noyeux Joël, que les jolis flocons et le cholestérol te soient propices en cette fin d&#8217;année!]]></content:encoded>
			<wfw:commentRss>http://www.memepasmal.ch/2010/12/24/oui-mais-pas-toujours/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Dictatorship Blocker 1.0</title>
		<link>http://www.memepasmal.ch/2010/06/16/dictablocker/</link>
		<comments>http://www.memepasmal.ch/2010/06/16/dictablocker/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 07:32:35 +0000</pubDate>
		<dc:creator>gael</dc:creator>
				<category><![CDATA[Foutoir technologique]]></category>
		<category><![CDATA[libye]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.memepasmal.ch/?p=1151</guid>
		<description><![CDATA[Que sommes-nous, nous autres citoyens du bas-peuple face à la puissance de nos dirigeants? Nous sommes faibles, nos moyens d'actions sont limités et l'on se sent souvent impuissant lorsqu'éclate une crise diplomatique menant à une situation injuste. Ce fût récemment le cas lors du conflit entre la Suisse et la Libye, on peut annoncer sans [...]]]></description>
			<content:encoded><![CDATA[Que sommes-nous, nous autres citoyens du bas-peuple face à la puissance de nos dirigeants? Nous sommes faibles, nos moyens d'actions sont limités et l'on se sent souvent impuissant lorsqu'éclate une crise diplomatique menant à une situation injuste.<br />
<br />
Ce fût récemment le cas lors du conflit entre la Suisse et la Libye, on peut annoncer sans grand doute que la majorité des citoyens de ce pays auraient aimé passer quelques minutes dans une cave avec un certain colonel menotté à un des pilliers de soutien.<br />
<br />
Au lieu de cela on rumine, on marmonne, on gueule sur nos blogs sans que cela n'aie aucune influence sur l'affaire en question. Ce billet sera d'ailleurs le dernier sur le sujet.<br />
<br />
Alors qu'au fond l'union fait la force, et nous autres petites gens avons un certain pouvoir, une certaine capacité d'action selon nos compétences respectives. Mon domaine de prédilection est l'informatique, plus précisément le développement. Ne pouvant rester les bras croisés je vais aujourd'hui te montrer comme devenir ce que l'on appelle un "<em>cyber-dissident</em>" , qui est en gros un dissident politique n'ayant juste pas les balles nécessaires pour aller protester en personne.<br />
<br />
Concrètement, je vais te montrer comment bloquer l'accès à tous les visiteurs libyens sur ton site. Tu noteras l'existence d'un <em>plugin</em> pour <em>WordPress</em> qui fait la même chose, j'en avais <a href="http://www.memepasmal.ch/2010/03/18/iq-block-countries/">déjà parlé</a>, c'est juste que tout le monde n'a pas <em>WordPress</em> et que c'est beaucoup plus marrant de le faire à la main.<br />
<br />
Bref, tu l'auras deviné, ce billet s'adresse à toi, honorable <em>webmistress</em> ou <em>webmaster</em> helvétique, lorsqu'un bédouin sous sa tente tapera ton URL dans son navigateur il tombera bêtement sur une belle erreur "<em>403 - Forbidden</em>" .<br />
<br />
La condition <em>sine qua non</em> est d'avoir un serveur web qui supporte PHP, il te suffit ensuite d'y installer ce superbe outil du ouebe <em>two point zero</em> :<br />
<br />
<a href="/bin/dicta_blocker.zip"><img src="http://www.memepasmal.ch/wp-content/uploads/2010/06/dicta_blocker.jpg" alt="" title="dicta_blocker" width="642" height="402" class="aligncenter size-full wp-image-1154" /></a><br />
<br />
Pour la mise en œuvre c'est très simple, tu télécharges le kit en faisant un clic droit sur l'image du dessus, puis tu choisis "<em>Enregistrer la cible du lien sous...</em>" .<br />
<br />
Le fichier ZIP que tu télécharges contient quatre fichiers : "geoip.inc" , "geoip.php" , "GeoIP.dat" et la photo d'un chaton adorable. Tu vas envoyer les trois premiers fichiers dans la racine de ton site web via ton client FTP favori, je te conseille <a href="http://filezilla-project.org/">FileZilla</a>. Tu fais ensuite suivre la photo du chaton à tous tes amis en disant qu'il est trop mignon. La base de donnée permettant la géolocalisation est gratuite et distribuée sous license GPL, elle provient de l'excellent site <a href="http://www.maxmind.com/" target="_Blank">MaxMind</a>.<br />
<br />
Dans la racine de ton site web tu devrais avoir un fichier nommé "index.php" , voire "default.php" dans de très rares cas. Tu vas l'ouvrir, deux cas de figures peuvent se présenter.<br />
<br />
Si ton fichier d'index commence immédiatement par la balise d'ouverture de code PHP (à savoir "&lt;?php" ), il te suffit d'ajouter le code suivant juste à la ligne du dessous.<br />
<br />
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;geoip.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div><br />
<br />
Si ton fichier commence par du code HTML, c'est ce code que tu dois insérer en tout début de fichier, avant ledit code HTML.<br />
<br />
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;geoip.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div><br />
<br />
Attention, dans les deux cas il est très important qu'aucun caractère ne se trouve avant la balise d'ouverture PHP ("&lt;?php" pour rappel), pas même un simple espace ou un retour à la ligne! Ce point est crucial pour une raison intrinsèque au protocole HTTP, en l'occurrence l'envoi des <em>headers</em> avant tout code HTML.<br />
<br />
Une fois que ton fichier "index.php" est modifié alors ton site est immédiatement protégé, te voilà maintenant officiellement devenu protestataire! Tu peux même télécharger la mini-bannière et l'afficher fièrement sur ton site.<br />
<br />
<img src="http://www.memepasmal.ch/wp-content/uploads/2010/06/dicta_minibanner.jpg" alt="" title="dicta_minibanner" width="120" height="24" class="aligncenter size-full wp-image-1153" /><br />
<br />
Pour résumer les opérations : Téléchargement du fichier ZIP, décompression du fichier ZIP, envoi des trois fichiers à la racine de ton site web, édition du fichier "index.php" . Je te passe l'étape du chaton.<br />
<br />
Tu pourras peut-être constater sur place l'efficacité de ce script le jour où toi aussi tu seras injustement enfermé dans une geôle libyenne, à condition d'avoir un accès à Internet bien entendu.]]></content:encoded>
			<wfw:commentRss>http://www.memepasmal.ch/2010/06/16/dictablocker/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Veilles pubs</title>
		<link>http://www.memepasmal.ch/2010/06/08/veilles-pubs/</link>
		<comments>http://www.memepasmal.ch/2010/06/08/veilles-pubs/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 12:55:02 +0000</pubDate>
		<dc:creator>gael</dc:creator>
				<category><![CDATA[Foutoir technologique]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[publicité]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.memepasmal.ch/?p=1125</guid>
		<description><![CDATA[Diffuser de la publicité sur son blog sans emmerder ses visiteurs réguliers n&#8217;est pas une tâche facile. Il existe actuellement plusieurs solutions, comme par exemple celle qui consiste à afficher les bandeaux publicitaires uniquement aux visiteurs qui proviennent des moteurs de recherches. En plus ou à la place de cette solution, on peut ajouter une [...]]]></description>
			<content:encoded><![CDATA[Diffuser de la publicité sur son blog sans emmerder ses visiteurs réguliers n&#8217;est pas une tâche facile. Il existe actuellement plusieurs solutions, comme par exemple celle qui consiste à afficher les bandeaux publicitaires uniquement aux visiteurs qui proviennent des moteurs de recherches.<br />
<br />
En plus ou à la place de cette solution, on peut ajouter une autre technique qui consiste à afficher lesdites publicités (ou tout autre code HTML) uniquement sur les vieux billets, ceux qui ont plus d&#8217;un certain nombre de jours.<br />
<br />
La solution existe en tant que plugin pour WordPress, mais c&#8217;est beaucoup moins drôle que le <em>hack</em> que je vais te présenter aujourd&#8217;hui.<br />
<br />
Pour commencer tu vas éditer le fichier &laquo;&nbsp;single.php&nbsp;&raquo; qui se trouve dans le répertoire de ton thème, normalement quelque chose comme &laquo;&nbsp;/wp-content/themes/ton_theme&nbsp;&raquo;. Tu places ensuite le code PHP suivant à l&#8217;endroit où tu veux que ta bannière s&#8217;affiche, n&#8217;oublie pas de l&#8217;encadrer par les balises PHP.<br />
<br />
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// Age du billet (en jours)</span><br />
<span style="color: #000088;">$nbjours</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span>get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Si le billet date de plus de 60 jours</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$nbjours</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Intégration du code de la bannière situé dans le fichier externe</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;adsense.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div><br />
<br />
Par exemple, si tu veux que ta bannière s&#8217;affiche avant ton billet, tu places le code précité juste après la ligne suivante.<br />
<br />
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main&quot;</span>&gt;</span></div></td></tr></tbody></table></div><br />
<br />
Tu noteras que dans cet exemple le code de la bannière publicitaire se trouve dans le fichier &laquo;&nbsp;adsense.php&nbsp;&raquo;, à toi de le créer et de le placer dans le répertoire de ton thème. Sinon, rien ne t&#8217;empêche d&#8217;afficher directement le code avec une ou plusieurs instructions &laquo;&nbsp;echo&nbsp;&raquo;.<br />
<br />
Tu peux même aller faire un tour sur mes vieux billets pour voir ce que ça donne, le menu &laquo;&nbsp;Archives&nbsp;&raquo; dans la barre latérale de droite te sera utile.<br />
]]></content:encoded>
			<wfw:commentRss>http://www.memepasmal.ch/2010/06/08/veilles-pubs/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Des vidéos sous WordPress</title>
		<link>http://www.memepasmal.ch/2010/05/01/des-videos-sous-wordpress/</link>
		<comments>http://www.memepasmal.ch/2010/05/01/des-videos-sous-wordpress/#comments</comments>
		<pubDate>Sat, 01 May 2010 08:47:22 +0000</pubDate>
		<dc:creator>gael</dc:creator>
				<category><![CDATA[Foutoir technologique]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.memepasmal.ch/?p=1082</guid>
		<description><![CDATA[N&#8217;ayant à ce jour pas trouvé de plugin pour WordPress permettant l&#8217;ajout de vidéos sur mon blog selon mes besoins précis, je me suis lancé dans le codage d&#8217;un petit hack qui a finalement répondu à mes attentes. Pour suivre cette manipulation il suffit d&#8217;avoir une légère maitrise de PHP, du XHTML ainsi que savoir [...]]]></description>
			<content:encoded><![CDATA[<p>N&#8217;ayant à ce jour pas trouvé de <em>plugin</em> pour WordPress permettant l&#8217;ajout de vidéos sur mon <em>blog</em> selon mes besoins précis, je me suis lancé dans le codage d&#8217;un petit <em>hack</em> qui a finalement répondu à mes attentes. Pour suivre cette manipulation il suffit d&#8217;avoir une légère maitrise de PHP, du XHTML ainsi que savoir se servir d&#8217;un client FTP.</p>
<p>Je n&#8217;utilise pas d&#8217;espace de stockage public tels que <a href="http://www.youtube.com/">Youtube</a> ou <a href="http://www.dailymotion.com/fr">Dailymotion</a> pour mes vidéos, tout est enregistré sur mon serveur web. J&#8217;utilise depuis longtemps le lecteur vidéo JW Player de chez <a href="http://www.longtailvideo.com/">Longtail</a>, il peut être téléchargé gratuitement pour une utilisation non commerciale. Il est écrit en Flash et reconnait la plupart des formats du web (flv, mp4, etc.).</p>
<p>Intégrer une vidéo dans un billet en utilisant ce lecteur est une sinécure, le code HTML est énorme et rébarbatif, d&#8217;où l&#8217;idée d&#8217;utiliser les <em>shortcodes</em> de WordPress pour simplifier à l&#8217;extrême. Au final, l&#8217;insertion d&#8217;une vidéo dans un article se résume ainsi en une simple ligne écrite directement dans le texte du billet.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[flv file=&quot;mavideo.flv&quot; image=&quot;image.jpg&quot; width=&quot;300&quot; height=&quot;200&quot;]</div></td></tr></tbody></table></div>
<p>Ce <em>shortcode</em> &laquo;&nbsp;<em>flv</em>&nbsp;&raquo; permet au moyen des attributs de spécifier la vidéo, l&#8217;image facultative qui sera utilisée en attendant la lecture, la largeur et la hauteur. Il est important de noter que toutes les vidéos et toutes les images d&#8217;attente sont stockées dans un répertoire particulier et envoyées sur le serveur au moyen d&#8217;un client FTP, donc pas de belle interface dans le tableau de bord, tout est fait à la main. Dans l&#8217;exemple qui suit, le répertoire contenant ces fichiers est le répertoire &laquo;&nbsp;</em>/bin</em> &raquo;&nbsp;.<br />
<span id="more-1082"></span><br />
La première étape consiste à récupérer le lecteur vidéo JW Player depuis <a href="http://www.longtailvideo.com/players/jw-flv-player">le site de l&#8217;éditeur</a>. Attention à bien décocher la case &laquo;&nbsp;<em>Include Viral, a video sharing plugin</em>&nbsp;&raquo; avant de cliquer sur &laquo;&nbsp;<em>Download</em> &raquo;&nbsp;, sinon tu vas te retrouver avec un lecteur contenant le <em>plugin</em> &laquo;&nbsp;<em>Viral</em>&nbsp;&raquo; qui est extrêmement lourd, il t&#8217;affichera une page très soulante après chaque lecture.</p>
<p>Une fois le téléchargement de l&#8217;archive terminé, tu la décompresses où bon te semble. Tu n&#8217;auras besoin que de deux fichiers, &laquo;&nbsp;<em>swfobject.js</em>&nbsp;&raquo; et &laquo;&nbsp;<em>player.swf</em> &raquo;&nbsp;, tu les envoies dans la racine de ton site web <em>via</em> ton client FTP favori. Si tu as le fichier &laquo;&nbsp;<em>player-viral.swf</em>&nbsp;&raquo; à la place c&#8217;est que tu as téléchargé le lecteur contenant le  <em>plugin</em> &laquo;&nbsp;<em>Viral</em> &raquo;&nbsp;, tu viendras pas te plaindre.</p>
<p>La seconde étape est la mise en place du <em>hack</em>. Tu vas aller ouvrir le fichier &laquo;&nbsp;<em>functions.php</em>&nbsp;&raquo; qui se trouve dans le répertoire de ton thème WordPress. Normalement le chemin est &laquo;&nbsp;<em>/wp-content/themes/ton_theme</em> &raquo;&nbsp;. Tu y ajoute le code suivant, bien entendu entre les balises PHP.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:200px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// Shortcode FLV function</span><br />
<span style="color: #666666; font-style: italic;">// Author : http://www.memepasmal.ch</span><br />
<span style="color: #000000; font-weight: bold;">function</span> flv_func<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Répertoire des vidéos, change-le si tu veux</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$repmedia</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/bin/&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// L'ID du DIV doit être unique</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$div</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;media&quot;</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;">999999</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Extraction des attributs</span><br />
&nbsp; &nbsp; <span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'file'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'image'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'width'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'320'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'height'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'240'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Construction du code HTML</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;div style='text-align:center;' id='&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$div</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'&gt;&lt;/div&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;script type='text/javascript'&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;var so = new SWFObject('/player.swf','single','&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;width&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;','&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;height&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;','0');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.addParam('allowfullscreen','true');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.addParam('allowscriptaccess','always');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.addParam('wmode','opaque');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.addParam('autostart','false');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.addParam('controlbar','bottom');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.addVariable('file','&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$repmedia</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;file&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;image&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.addVariable('image','&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$repmedia</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;image&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.write('&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$div</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/script&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$html</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Cette fonction PHP sera utilisée par notre futur <em>shortcode</em>. Tu noteras la présence de la ligne permettant d&#8217;indiquer le répertoire des fichiers vidéos.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$repmedia</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/bin/&quot;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Tu peux modifier &laquo;&nbsp;<em>/bin/</em>&nbsp;&raquo; avec le nom de ton répertoire qui contient tes médias. Attention à bien terminer par un slash.</p>
<p>Juste après l&#8217;accolade finale de cette fonction, toujours dans le fichier &laquo;&nbsp;<em>functions.php</em>&nbsp;&raquo; tu ajoutes la ligne suivante qui a pour but la création du <em>shortcode</em> &laquo;&nbsp;<em>flv</em> &raquo;&nbsp;.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// Ajout du shortcode</span><br />
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'flv'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'flv_func'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>La dernière étape consiste à intégrer le code JavaScript qui permet au lecteur de fonctionner. Tu vas donc aller ouvrir le fichier &laquo;&nbsp;<em>header.php</em>&nbsp;&raquo; qui se trouve dans le répertoire de ton thème, et tu vas ajouter la ligne suivante à la suite des balises HTML. Attention à l&#8217;emplacement, normalement ce code devrait se trouver entre les balises &laquo;&nbsp;<em>&lt;head&gt;</em>&nbsp;&raquo; et &laquo;&nbsp;</em>&lt;/head&gt;</em>.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'text/javascript'</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'/swfobject.js'</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></div></td></tr></tbody></table></div>
<p>Tu envoies les deux fichiers &laquo;&nbsp;<em>functions.php</em>&nbsp;&raquo; et &laquo;&nbsp;<em>header.php</em>&nbsp;&raquo; modifiés sur ton serveur et le tour est joué, tu peux maintenant utiliser le <em>shortcode</em> nommé &laquo;&nbsp;<em>flv</em>&nbsp;&raquo; pour intégrer facilement des vidéos dans tes billets.</p>
<p>Par exemple, pour jouer le fichier vidéo &laquo;&nbsp;<em>mpm.flv</em>&nbsp;&raquo; de 320 pixels par 240, avec comme image d&#8217;attente &laquo;&nbsp;<em>mpm.jpg</em> &raquo;&nbsp;.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[flv file=&quot;mpm.flv&quot; image=&quot;mpm.jpg&quot; width=&quot;320&quot; height=&quot;240&quot;]</div></td></tr></tbody></table></div>
<p>Ce code affichera le résultat suivant aux visiteurs.</p>
<p><div class="video" style="width:320px;">
<div id='video786114'></div>
<script type='text/javascript'>
  var so = new SWFObject('/player.swf','single','320','264','0');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addParam('autostart','false');
  so.addParam('controlbar','bottom');
  so.addParam('dock','false');
  so.addVariable('file','/bin/mpm.flv');
  so.addVariable('image','/bin/mpm.jpg');
  so.write('video786114');
</script>
</div>
</p>
<p>L&#8217;attribut &laquo;&nbsp;<em>image</em>&nbsp;&raquo; est optionnel. Voici le code pour jouer ce même fichier vidéo, mais sans image d&#8217;attente.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[flv file=&quot;mpm.flv&quot; width=&quot;320&quot; height=&quot;240&quot;]</div></td></tr></tbody></table></div>
<p>Une petite astuce pour terminer, si malgré tous mes avertissements tu as téléchargé le lecteur incluant le plugin Viral et que tu as la flemme de télécharger une version sans cette lourdeur supplémentaire, il te suffit d&#8217;ajouter ces quelques lignes à la fonction PHP (au milieu de celles qui se ressemblent) pour désactiver cet horrible message de partage en fin de vidéo.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.addVariable('viral.allowmenu','false');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.addVariable('viral.onpause','false');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$html</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &nbsp;so.addVariable('viral.oncomplete','false');<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>C&#8217;est à toi de jouer maintenant.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.memepasmal.ch/2010/05/01/des-videos-sous-wordpress/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Kikoololise ton site!</title>
		<link>http://www.memepasmal.ch/2008/04/18/kikoololise-ton-site/</link>
		<comments>http://www.memepasmal.ch/2008/04/18/kikoololise-ton-site/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 19:45:36 +0000</pubDate>
		<dc:creator>gael</dc:creator>
				<category><![CDATA[Foutoir technologique]]></category>
		<category><![CDATA[kikoolol]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[udc]]></category>
		<category><![CDATA[zelune]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Je me rends compte avec amertume que certains blogs de qualité ne reçoivent que peu de visiteurs si on les compare aux nombreux skyblogs (le terme est entré dans les mœurs) qui abondent sur la toile. Se mettre à niveau n&#8217;est franchement pas simple, surtout si ça tend franchement vers le bas. Ainsi donc, n&#8217;arrivant [...]]]></description>
			<content:encoded><![CDATA[Je me rends compte avec amertume que certains blogs de qualité ne reçoivent que peu de visiteurs si on les compare aux nombreux skyblogs (le terme est entré dans les mœurs) qui abondent sur la toile. Se mettre à niveau n&#8217;est franchement pas simple, surtout si ça tend franchement vers le bas.<br />
<br />
Ainsi donc, n&#8217;arrivant décemment pas à gerber -volontairement- une faute d&#8217;orthographe, j&#8217;ai mis à profit mes immenses qualités de développeur PHP pour vous pondre le, <em>*roulements de tambours*</em> <a href="http://kikoolol.memepasmal.net/">Kikoololisateur de site</a>!<br />
<br />
Attention c&#8217;est pas facile à prononcer.<br />
<br />
Basé sur le célèbre proxy web <a href="http://www.zelune.com/">Zelune</a> (complètement détourné pour l&#8217;occasion), adapté à la sauce <em>geek</em>, douze jours de travail sans dormir, ni manger, ni aller aux toilettes, sauf pour me torcher avec des publicités racistes.<br />
<br />
Bon, c&#8217;est encore une version bêta (mais ça ne veut pas dire qu&#8217;elle est conne), donc des fois ça merdoie et il faut recharger la page. Et puis ça fonctionne pas pour tous les sites, les CSS intégrés et les commentaires dans les commentaires c&#8217;est parfois galère à gérer pour un pauvre petit script amateur.<br />
<br />
Bref.<br />
<br />
Quelques exemples de blogs : <a href="http://kikoolol.memepasmal.net/?q=aHR0cDovL3d3dy5wb3VyYWluc2lkaXJlLmNvbS8%3D&amp;hl=1ed">Pour ainsi dire</a>, <a href="http://kikoolol.memepasmal.net/?q=aHR0cDovL3Zpcmd1bGVzLm92ZXItYmxvZy5jb20v&amp;hl=1ed">les virgules de l&#8217;Arpenteur</a>,  <a href="http://kikoolol.memepasmal.net/?q=aHR0cDovL3plYnJhYmxvZy5uZXQvc3VndXMvaW5kZXgucGhwLw%3D%3D&amp;hl=1ed">Sugus</a>, <a href="http://kikoolol.memepasmal.net/?q=aHR0cDovL2dub2x1LnJvbWFuZGllLmNvbS8%3D&amp;hl=1ed">le Gnolu</a>, <a href="http://kikoolol.memepasmal.net/?q=aHR0cDovL3d3dy5ib25wb3VydG9ucG9pbC5jaC8%3D&amp;hl=1ed">Bon pour ton poil</a> et quand même l&#8217;incontournable <a href="http://kikoolol.memepasmal.net/?q=d3d3Lm1lbWVwYXNtYWwubmV0&amp;hl=1ed">même pô mal</a>.<br />
<br />
Quelques sites politiques devenus enfin intéressants : <a href="http://kikoolol.memepasmal.net/?q=d3d3LnVkYy1nZS5jaA%3D%3D&amp;hl=1ed">UDC Genève</a>, le <a href="http://kikoolol.memepasmal.net/?q=aHR0cDovL3d3dy5ldnBwZXYuY2gvaW5kZXgucGhwP2lkPTgmTD0x&amp;hl=1ed">PEV</a>, le <a href="http://kikoolol.memepasmal.net/?q=aHR0cDovL3d3dy5jdnAuY2gvZnIvaG9tZS9ob21lLmh0bWw%3D&amp;hl=1ed">PDC</a><br />
<br />
Quelques sites de lecture : <a href="http://kikoolol.memepasmal.net/?q=d3d3LmxlbWF0aW4uY2g%3D&amp;hl=1ed">Le Matin</a>, la <a href="http://kikoolol.memepasmal.net/?q=d3d3LnRkZy5jaA%3D%3D&amp;hl=1ed">Tribune de Genève</a><br />
<br />
Si ton site est pas dans la liste c&#8217;est pas que je t&#8217;aime pas, c&#8217;est que le <a href="http://kikoolol.memepasmal.net/">kikoololisateur</a> ne fonctionne pas encore très bien.<br />
<br />
Enjoy.<br />
<br />
lol.]]></content:encoded>
			<wfw:commentRss>http://www.memepasmal.ch/2008/04/18/kikoololise-ton-site/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
	</channel>
</rss>

