<?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>nFrey.com &#124; Nicolas FREY &#187; Développement</title>
	<atom:link href="http://www.nfrey.com/cat/developpement/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nfrey.com</link>
	<description>Fais du Web 2.0 un idéal, et d'un idéal une réalité</description>
	<lastBuildDate>Fri, 27 Feb 2009 14:59:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mozilla Firefox &#8211; Extensions et développement</title>
		<link>http://www.nfrey.com/internet/extension-firefox-dev/</link>
		<comments>http://www.nfrey.com/internet/extension-firefox-dev/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 14:24:45 +0000</pubDate>
		<dc:creator>Nicolas Frey</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://www.nfrey.com/?p=100</guid>
		<description><![CDATA[Mozilla Firefox est l'un de mes navigateurs préférés. Pas seulement pour développer, mais aussi pour ses performances, son interface, et son lot d'extension fort sympatique.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mozilla-europe.org/fr/firefox/" target="_blank">Mozilla Firefox</a> est l&#8217;un de mes navigateurs préférés. Pas seulement pour développer, mais aussi pour ses performances, son interface, et son lot d&#8217;extensions fort sympathique.</p>
<p><span id="more-100"></span>Il existe de nombreuses extensions qui apportent un gain considérable dans l&#8217;utilisation de Firefox. Voici la liste des extensions que l&#8217;utilise couramment:</p>
<ul>
<li><strong>Adblock Plu</strong>s: Pour supprimer la publicité</li>
<li><strong>DownloadThemAll</strong>: Pour accélérer les téléchargements</li>
<li><strong>Firebug</strong>: Pour déboguer une page html/javascript</li>
<li><strong>Foxmark</strong>: Pour sauvegarder marque-pages et mots de passe</li>
<li><strong>Tab Mix Plus</strong>: Pour une gestion améliorée des onglets</li>
<li><strong>Web Developer</strong>: Une barre d&#8217;outils pour le développement</li>
</ul>
<p>Tous ses outils sont vraiment très bien, je vous propose donc deux liens qui vous les présentent plus précisément.</p>
<ul>
<li><strong>Alsacreations<br />
 </strong>Vous y trouverez un article qui reprends les 20 meilleures extensions Firefox pour développeurs web. (<a href="https://addons.mozilla.org/fr/firefox/addon/1843" target="_blank">Firebug</a>, <a href="https://addons.mozilla.org/fr/firefox/addon/60" target="_blank">WebDeveloper Toolbar</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/249" target="_blank">Validateurs</a>, <a href="https://addons.mozilla.org/fr/firefox/addon/35" target="_blank">IE Tab</a>, <a href="https://addons.mozilla.org/fr/firefox/addon/271" target="_blank">Colorzilla</a>, <a href="https://addons.mozilla.org/fr/firefox/addon/5648" target="_blank">Fireshot</a>, <a href="https://addons.mozilla.org/fr/firefox/addon/5392" target="_blank">Dust-me Selectors</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/539" target="_blank">MeasureIt</a>, <a href="http://smush.it/" target="_blank">SmushIt</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/6149" target="_blank">FirePHP</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/3829" target="_blank">Live HTTP Headers</a>, <a href="https://addons.mozilla.org/fr/firefox/addon/1802" target="_blank">X-Ray</a>, <a href="https://addons.mozilla.org/fr/firefox/addon/748" target="_blank">Greasemonkey</a>, &#8230;)<br />
 Voici le lien: <a href="http://www.alsacreations.com/actu/lire/645-les-20-meilleures-extensions-firefox-pour-dveloppeurs-web.html" target="_blank">http://www.alsacreations.com</a></li>
<li><strong>Developpez.com</strong><br />
 Vous y trouverez un article sur les meilleurs extensions Firefox. Principalement orienté pour le développeur. (<a href="http://adblock.mozdev.org/" target="_blank">Adblock</a>, <a href="https://addons.mozilla.org/fr/firefox/addon/35" target="_blank">IE tab</a>, <a href="http://extensions.geckozone.org/GetJetableMail" target="_blank">GetJetableMail</a>, <a href="http://extensions.geckozone.org/TabMixPlus" target="_blank">Tab Mix plus</a>, <a href="http://extensions.geckozone.org/ScrapBook" target="_blank">ScrapBook</a>, <a href="http://joliclic.free.fr/mozilla/webdeveloper/" target="_blank">Web developer</a>, <a href="https://addons.mozilla.org/firefox/918/" target="_blank">Gtranslate</a>, <a href="http://extensions.geckozone.org/FireFTP" target="_blank">FireFTP</a>, <a href="http://frenchmozilla.sourceforge.net/cz/" target="_blank">ChatZilla</a>, <a href="https://addons.mozilla.org/firefox/135/" target="_blank">SecurePassword</a>, <a href="https://addons.mozilla.org/firefox/655/" target="_blank">View Source Chart</a>, <a href="https://addons.mozilla.org/firefox/1843/" target="_blank">Firebug</a>, &#8230;)<br />
 Voici le lien: <a href="http://lgmorand.developpez.com/articles/extensions-firefox/" target="_blank">http://www.developpez.com</a></li>
</ul>
<p>Avec ces deux articles, vous voilà parti pour travailler plus facilement et proprement avec Firefox.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nfrey.com/internet/extension-firefox-dev/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sortie des EzComponents 2008.2</title>
		<link>http://www.nfrey.com/ezpublish/ezcomponent-20082/</link>
		<comments>http://www.nfrey.com/ezpublish/ezcomponent-20082/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 11:51:26 +0000</pubDate>
		<dc:creator>Nicolas Frey</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[eZPublish]]></category>
		<category><![CDATA[ezcomponents]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.nfrey.com/?p=238</guid>
		<description><![CDATA[Chose promise chose due, avec très peu de retard les nouveaux EzComponents viennent de voir le jour.]]></description>
			<content:encoded><![CDATA[<p>Chose promise chose due, avec très peu de retard les nouveaux EzComponents viennent de voir le jour.</p>
<p><span id="more-238"></span></p>
<h2>EzComponent c&#8217;est quoi ?</h2>
<p><a href="http://ez.no/fr/ezcomponents" target="_blank">eZ Components</a> sont des librairies PHP prêtes à l&#8217;emploi dédiées aux entreprises qui peuvent être utilisées ensemble ou de manière indépendante pour le développement d&#8217;applications PHP. Avec <a href="http://ez.no/fr/ezcomponents" target="_blank">eZ Components</a>, les développeurs peuvent se concentrer sur les besoins spécifiques à leurs applications sans à avoir à tout réinventer. Les dernières versions d&#8217; <a href="http://ez.no/fr/ezpublish">eZ Publish</a> sont basées sur <a href="http://ez.no/fr/ezcomponents" target="_blank">eZ Components</a>.</p>
<h2>Les nouveautés pour 2009<br class="spacer_" /></h2>
<ul>
<li>Amélioration du composant MVC tools, qui permet une meilleure utilisation du modèle <a href="http://fr.wikipedia.org/wiki/Mod%C3%A8le-Vue-Contr%C3%B4leur" target="_blank">MVC</a>.</li>
<li>De nouveaux formats sont pris en charge par le composant Document  (Confluence, Creole et DokuWiki), qui permet la conversion de documents sous différents formats. Il est par exemple possible de convertir du ReST en XHTML ou DocBook.</li>
<li>Le composant Webdav a été également amélioré et supporte maintenant l&#8217;authentification et la gestion des autorisations</li>
<li>Pour cette version, l&#8217;équipe de développeurs a corrigé, 55 bugs et implémenté 43 nouvelles fonctionnalités.</li>
</ul>
<p>Par rapport à la roadmap, il me semblait qu&#8217;il devait y avoir des changements sur les fluxRSS et la gestion du cache, mais je n&#8217;ai rien trouvé qui en parlait. Surement dans la prochaine version&#8230;</p>
<p><br class="spacer_" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nfrey.com/ezpublish/ezcomponent-20082/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sortie de Zend Framework 1.7.0</title>
		<link>http://www.nfrey.com/zendframework/zend-framework-17/</link>
		<comments>http://www.nfrey.com/zendframework/zend-framework-17/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 13:50:50 +0000</pubDate>
		<dc:creator>Nicolas Frey</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.nfrey.com/?p=209</guid>
		<description><![CDATA[Zend et Adobe ont annoncé, lors du salon Adobe MAX, la sortie de la version 1.7 du Zend Framework. Celui ci supporte désormais le format Zend_AMF (Action script Messaging Format). Les deux sociétés se sont associées afin de rendre plus facile le développement d'applications Internet Riches basées sur l'intégration de PHP et du framework Flex.]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: 8.5pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;"><a href="http://www.zend.com/fr/" target="_blank">Zend</a> et <a href="http://www.adobe.com/" target="_blank">Adobe</a> ont annoncé, lors</span><span style="font-size: 8.5pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;"> du salon <a href="http://max.adobe.com/" target="_blank">Adobe MAX</a>, la sortie de la version 1.7 du Zend Framework. Celui ci supporte désormais le format Zend_AMF (Action script Messaging Format). </span><span style="font-size: 8.5pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Les deux sociétés se sont associées afin de rendre plus facile le développement d&#8217;applications Internet Riches basées sur l&#8217;intégration de PHP et de <a href="http://www.adobe.com/fr/products/flex/" target="_blank">Flex</a>.</span></p>
<p><span id="more-209"></span>La nouvelle version du Zend Framework est disponible en téléchargement depuis <a href="http://framework.zend.com/">le site de Zend</a>. Et voici la liste des nouveautés:</p>
<ul>
<li style="text-align: left;">Zend_Amf avec support des protocoles AMF0 et AMF3. (Pour flex) </li>
<li style="text-align: left;"><a href="http://dojotoolkit.org/" target="_blank">Dojo Toolkit 1.2.1</a></li>
<li style="text-align: left;">Gestion du <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/advanced-editing-and-display/editor-rich-text" target="_blank">Dijit Editor</a>, un éditeur WYSIWYG Dojo. </li>
<li style="text-align: left;">Zend_Service_Twitter: Implémentation de l&#8217;API Twitter </li>
<li style="text-align: left;">ZendX_JQuery. Un helper pour simplifier l&#8217;utilisation de <a href="http://jquery.com/" target="_blank">jQuery</a> et <a href="http://ui.jquery.com/" target="_blank">UI jQuery</a> </li>
<li style="text-align: left;">Zend_Cache: Une API gérant les Métadata </li>
<li style="text-align: left;">Zend_Gdata: Une API de recherche Google book </li>
<li style="text-align: left;">Zend_Gdata: Gestion préliminaire du Protocole version 2 de GData. </li>
<li style="text-align: left;">Zend_Search_Lucene: &laquo;&nbsp;Skip data processing&nbsp;&raquo;</li>
<li style="text-align: left;">Zend_Search_Lucene: Indexation de document Open Office XML </li>
<li style="text-align: left;">Amélioration des performances dans Zend_Loader, Zend_Controller, et les composants serveurs </li>
<li style="text-align: left;">Zend_Mail_Storage_Writable_Maildir: Amélioration de l&#8217;envoi de mail</li>
<li style="text-align: left;">Zend_Tool: Dans l&#8217;incubateur (Webservice, gestion de projet, et Génération de code)</li>
<li style="text-align: left;">Zend_Text_Table: Pour la mise en forme de tableau de type texte. </li>
<li style="text-align: left;">Zend_ProgressBar: Pour créer et mettre à jour les barres de progression dans différents environnements. </li>
<li style="text-align: left;">Zend_Config_Writer: Pour la création de fichiers de configuration à partir d&#8217;objets Zend_Config. </li>
<li style="text-align: left;">ZendX_Console_Unix_Process: Permet de créer des processus s&#8217;exécutant dans un shell. </li>
<li style="text-align: left;">Zend_Db_Table_Select: Gestion du &laquo;&nbsp;Zend_Paginator&nbsp;&raquo; pour la pagination des données. </li>
<li style="text-align: left;">Paramètres globaux pour les routes. </li>
<li style="text-align: left;">Utilisation des Routes Chainées pour les Hostname-Routes via Zend_Config. </li>
<li style="text-align: left;">Amélioration I18N (Internationalisation)
<ul>
<li style="text-align: left;">Zend_Translate API simplifié, mise à jour des méthodes de gestion du cache&#8230; </li>
</ul>
</li>
<li style="text-align: left;">Amélioration du transfert de fichier
<ul>
<li>Gestion des &laquo;&nbsp;file elements&nbsp;&raquo; dans les &laquo;&nbsp;subforms&nbsp;&raquo;</li>
<li>Gestion des &laquo;&nbsp;multifiles elements&nbsp;&raquo;</li>
<li>Gestion du &laquo;&nbsp;MAX_FILES_SIZE&nbsp;&raquo; dans un formulaire</li>
<li>Gestion des erreurs dans la chaine de validation</li>
<li>Gestion de la traduction sur les erreurs et les messages. </li>
<li>Nouveau validateur: IsCompressed, IsImage, ExcludeMimeType, ExcludeExtension</li>
<li>Gestion du &laquo;&nbsp;FileInfo&nbsp;&raquo; dans le &laquo;&nbsp;MimeType&nbsp;&raquo; validateur</li>
</ul>
</li>
<li style="text-align: left;">Gestion d&#8217;adaptateur personnalisé dans &laquo;&nbsp;Zend_Paginator&nbsp;&raquo;</li>
<li style="text-align: left;">Plus de liberté dans la gestion des types complexes dans &laquo;&nbsp;Zend_Soap&nbsp;&raquo;</li>
<li style="text-align: left;">Et beaucoup de bugs de corrigés &#8230;</li>
</ul>
<p>Ce Framework est vraiment prometteur, après une version 1.5 très riche en nouveautés notamment autour de la gestion de formulaires, des layouts et du support d&#8217;AJAX. La version 1.7 apporte un bon nombre de changements appréciables et les idées n&#8217;ont pas l&#8217;air de manquer pour les prochaines versions &#8230;.</p>
<p>A quand mon prochain projet Zend que je puisse m&#8217;amuser un peu avec toutes ses nouveautés ?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nfrey.com/zendframework/zend-framework-17/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Une URL raccourcie sur votre domaine &#8230; pourquoi pas vous ?</title>
		<link>http://www.nfrey.com/internet/tinyurl/</link>
		<comments>http://www.nfrey.com/internet/tinyurl/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 13:43:20 +0000</pubDate>
		<dc:creator>Nicolas Frey</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[courte]]></category>
		<category><![CDATA[raccourci]]></category>
		<category><![CDATA[short]]></category>
		<category><![CDATA[tinyurl]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.nfrey.com/?p=132</guid>
		<description><![CDATA[Il existe beaucoup de site pour faire des URL courte mais pourquoi ne pas le faire sur votre propre domaine ? ]]></description>
			<content:encoded><![CDATA[<p>Il existe beaucoup de site pour faire des raccourcies URL mais pourquoi ne pas le faire sur votre propre domaine ?</p>
<p><span id="more-132"></span></p>
<p>Le développement est relativement simple, il suffit d&#8217;un serveur acceptant le <a href="http://fr.wikipedia.org/wiki/PHP:_Hypertext_Preprocessor" target="_blank">PHP</a>, d&#8217;une base de données et si possible la redirection d&#8217;url activé (<a href="http://en.wikipedia.org/wiki/Rewrite_engine" target="_blank">mod_rewrite</a> sous <a href="http://www.apache.org/" target="_blank">Apache</a>). Le développement tient dans un script et un fichier .htaccess pour la redirection des URL.</p>
<p>La base de données contient une table avec un identifiant unique qui représente la clé d&#8217;accès et l&#8217;URL du lien sur lequel on veut rediriger.</p>

<div class="wp_codebox"><table><tr id="p1321"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p132code1"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`tinyurl`</span> <span style="color: #66cc66;">&#40;</span>
  <span style="color: #ff0000;">`hash`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">16</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`url`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">default</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`hash`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Le script PHP est loin d&#8217;être du code objet ou encore utiliser Zend Framework, mais pour un petit outil du genre un bon vieux code en procédural devrait faire l&#8217;affaire. Le script n&#8217;est pas très complexe. On a une partie pour afficher le formulaire, une fonction pour la création du hash, l&#8217;enregistrement dans la base de données et une fonction pour rechercher l&#8217;URL associé au <a href="http://fr.wikipedia.org/wiki/Hash" target="_blank">hash</a>.</p>

<div class="wp_codebox"><table><tr id="p1322"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
</pre></td><td class="code" id="p132code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Fichier qui contient les paramètres de connexion.</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'config.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Connexion à la base de donnée
 */</span>
<span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span>DB_HOST<span style="color: #339933;">,</span> DB_USER<span style="color: #339933;">,</span> DB_PASSWORD<span style="color: #009900;">&#41;</span>
        or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Impossible de se connecter&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span>DB_NAME<span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;tinyurl&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HASHSIZE'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Taille du hash</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Recherche par rapport au hash passé en paramètre
 * et redirection sur l'URL.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> renvoyer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$table</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>is_hash<span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #000088;">$req</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM <span style="color: #006699; font-weight: bold;">$table</span> WHERE hash = '<span style="color: #006699; font-weight: bold;">$hash</span>';&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$req</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Query failed&quot;</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;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;Aucun id associé&quot;</span><span style="color: #339933;">;</span>
       <span style="color: #b1b100;">return</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;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_result</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;url&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Enregistrement de l'url avant son identifiant.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> enregistrer<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$url</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$table</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">print</span> <span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;HTML
                 &lt;span class=&quot;error&quot;&gt;
                    &lt;i&gt;{$url}&lt;/i&gt; n'est pas une url valide
                 &lt;/span&gt;
HTML</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Test si l'url existe déjà et retourne le hash correspondant.</span>
   <span style="color: #666666; font-style: italic;">// Évite les doublons inutiles.</span>
   <span style="color: #000088;">$req</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT hash FROM <span style="color: #006699; font-weight: bold;">$table</span> WHERE url= '<span style="color: #006699; font-weight: bold;">$url</span>';&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$req</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Query failed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// L'url existe déjà dans la base de données</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</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;">&#123;</span>
      <span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_result</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hash&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// A modifier en fonction de votre .htaccess et</span>
      <span style="color: #666666; font-style: italic;">// des redirections d'url</span>
      <span style="color: #000088;">$adresse</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://votredomain/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$hash</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">print</span> <span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;HTML
		&lt;span class=&quot;info&quot;&gt;
                   Voici votre URL r&amp;amp;eacute;duite :
                &lt;/span&gt;
&nbsp;
{$adresse}
&nbsp;
HTML</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// L'url n'existe pas encore</span>
   <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Recherche un identifiant valide</span>
      <span style="color: #000088;">$ok</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$ok</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// Génération d'un hash</span>
	 <span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> generateHash<span style="color: #009900;">&#40;</span>HASHSIZE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	 <span style="color: #666666; font-style: italic;">// Test si le hash n'existe pas déjà dans la base de données</span>
  	 <span style="color: #000088;">$req</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT hash FROM <span style="color: #006699; font-weight: bold;">$table</span> WHERE hash= '<span style="color: #006699; font-weight: bold;">$hash</span>';&quot;</span><span style="color: #339933;">;</span>
	 <span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$req</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Query failed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// Aucun résultat le hash est donc dispo</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$ok</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// Nombre de tentative dépassée on arrête.</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$count</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Insertion de l'url dans la base de données</span>
      <span style="color: #000088;">$req</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO <span style="color: #006699; font-weight: bold;">$table</span> (hash, url) VALUES ('<span style="color: #006699; font-weight: bold;">$hash</span>', '<span style="color: #006699; font-weight: bold;">$url</span>');&quot;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Insertion ok</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$req</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #000088;">$adresse</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://nfrey.com/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$hash</span><span style="color: #339933;">;</span>
	 <span style="color: #b1b100;">print</span> <span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;HTML
	  	   &lt;span class=&quot;info&quot;&gt;
                       Voici votre URL r&amp;amp;eacute;duite :
                   &lt;/span&gt;
&nbsp;
{$adresse}
&nbsp;
HTML</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Erreur d'insertion</span>
      <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">print</span> <span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;HTML
		   &lt;span class=&quot;error&quot;&gt;
                      Une erreur s'est produite.
                   &lt;/span&gt;
HTML</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: #009933; font-style: italic;">/**
 * Vérification de l'url
 * La regex doit être grandement améliorée pour prendre en compte
 * tous les types d'url possible.
 * ex: protocole://sdo.domain.ext:port/dossier/file?param&amp;amp;autres#ancre
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> is_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$motif_url</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^^(http|ftp|https)://([a-zA-Z0-9-]+.)?([a-zA-Z0-9-]+.)
               ?[a-zA-Z0-9-]+.[a-zA-Z]{2,4}(:[0-9]+)?(/[a-zA-Z0-9-]*)
               ?(.[a-zA-Z0-9]{1,4})?$&quot;</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: #339933;">!</span><span style="color: #990000;">ereg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$motif_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">else</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Génération d'un identifiant celui ci contient
 * des caractères alpha-numériques.
 * On lui passe en paramètre la taille que devra avoir l'identifiant
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> generateHash<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$length</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
   <span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Caractères possibles</span>
   <span style="color: #000088;">$possible</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0123456789abcdefghijklmnopqrstuvwxyz
                ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
   <span style="color: #666666; font-style: italic;">// Compteur pour la taille du hash</span>
   <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> 
&nbsp;
   <span style="color: #666666; font-style: italic;">// ajoute un caractère aléatoirement au hash jusqu'à sa taille max</span>
   <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$length</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// Trouve un caractère de façon aléatoire dans la liste</span>
      <span style="color: #666666; font-style: italic;">// des caractères possibles</span>
      <span style="color: #000088;">$char</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$possible</span><span style="color: #339933;">,</span> <span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$possible</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> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Ne pas reprendre ce caractère s'il est déjà dans le hash</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #339933;">,</span> <span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #000088;">$hash</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$char</span><span style="color: #339933;">;</span>
	 <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// retour du résultat !</span>
   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$hash</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Vérification du hash
 * Doit contenir x caractères alpha numérique
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> is_hash<span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$motif_hash</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^([0-9A-Za-z]{&quot;</span> <span style="color: #339933;">.</span> HASHSIZE <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;})$&quot;</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: #339933;">!</span><span style="color: #990000;">ereg</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$motif_hash</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hash</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">else</span>
      <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Fonction d'affichage
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> affichage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Un id est passé en paramètre, on appel la fonction renvoyer</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      renvoyer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Retour du formulaire on créé une url, appel</span>
   <span style="color: #666666; font-style: italic;">// de la fonction enregistrer</span>
   <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'creer'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
              <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'creer'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'oui'</span><span style="color: #009900;">&#41;</span>
              <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
              <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      enregistrer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Affichage du formulaire pour la création de l'url</span>
   <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;HTML
&lt;form action=&quot;{$_SERVER['PHP_SELF']}&quot; method=&quot;POST&quot;&gt;
&lt;input type=&quot;hidden&quot; name=&quot;creer&quot; value=&quot;oui&quot; /&gt;
	  URL:
&lt;input type=&quot;text&quot; name=&quot;url&quot; value=&quot;http://&quot; /&gt;
&lt;input type=&quot;submit&quot; name=&quot;action&quot; value=&quot;R&amp;amp;eacute;duire&quot; /&gt;
	&lt;/form&gt;
&nbsp;
HTML</span><span style="color: #339933;">;</span>
  	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;html&gt;
   &lt;head&gt;
      &lt;title&gt;TinyURL&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
      <span style="color: #000000; font-weight: bold;">&lt;?php</span> affichage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
   &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Le hash sert donc à récupérer l&#8217;URL dans la base. L&#8217;URL récupérée depuis la base de donnée modifie aussitôt la page visualisée par l&#8217;utilisation de la fonction header().<br />
 Pour parfaire la chose, il faudrait créer un fichier .htaccess renvoyant les URL du type http://domaine/%hash% vers http://domaine/dossier/url.php?id=%hash% &#8230;.</p>
<p>Voici un exemple d&#8217;un fichier .htaccess</p>

<div class="wp_codebox"><table><tr id="p1323"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p132code3"><pre class="ini" style="font-family:monospace;"># Tester si le module apache existe
&lt;IfModule mod_rewrite.c&gt;
&nbsp;
   # démarre la réécriture d'url
   RewriteEngine On
&nbsp;
   # Redirection http://mondomaine/tinyurl sur le script php
   # <span style="">&#40;</span>créé un petit lien<span style="">&#41;</span>
   RewriteRule tinyurl$ /url/url.php
&nbsp;
   # Redirection http://mondomaine/tinyurl/%hash% sur le script
   # avec le paramètre id
   RewriteRule tinyurl/<span style="">&#40;</span><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>a-ZA-Z0-<span style="">9</span><span style="">&#93;</span>+<span style="">&#41;</span>$ /url/url.php?id<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">$1 <span style="">&#91;</span>L<span style="">&#93;</span></span></span>
&lt;/IfModule&gt;</pre></td></tr></table></div>

<p>Vous avez maintenant de quoi faire vos URL courtes sur votre site perso. Mon script est très légèrement différent et adapté pour être intégré dans <a href="http://wordpress.org/" target="_blank">Wordpress</a> vous pouvez le tester ici :</p>
<ul>
<li><a href="http://nfrey.com/LNS1e" target="_blank">http://nfrey.com/LNS1e</a></li>
</ul>
<p>Si vous avez des remarques ou questions, je reste joinable. Vous trouverez mes coordonnées sur la page &laquo;&nbsp;<a href="http://www.nfrey.com/a-propos/" target="_blank">à propos</a>&laquo;&nbsp;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nfrey.com/internet/tinyurl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Un IDE/EDI pour développer en PHP</title>
		<link>http://www.nfrey.com/developpement/eclipse-php/</link>
		<comments>http://www.nfrey.com/developpement/eclipse-php/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 15:19:10 +0000</pubDate>
		<dc:creator>Nicolas Frey</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[edi]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[utilisation]]></category>

		<guid isPermaLink="false">http://www.nfrey.com/?p=44</guid>
		<description><![CDATA[Un IDE, ou EDI en français, est un programme regroupant un éditeur de texte, compilateur, débogueur et plusieurs autres fonctionnalités comme de la coloration syntaxique, les gestions de versions, la comparaison de fichier, la recherche ou encore des outils pour faciliter la création de l'interface graphique.
Pour développer en PHP, il existe plusieurs solutions comme Notepad++, UltraEdit, Zend Studio ou encore Eclipse. ]]></description>
			<content:encoded><![CDATA[<p>Un IDE, ou EDI en français, est un programme regroupant un éditeur de texte, compilateur, débogueur et plusieurs autres fonctionnalités comme de la coloration syntaxique, les gestions de versions, la comparaison de fichier, la recherche ou encore des outils pour faciliter la création de l&#8217;interface graphique. <br />
 Pour développer en <a href="http://fr.wikipedia.org/wiki/Php" target="_blank">PHP</a>, il existe plusieurs solutions comme <a href="http://notepad-plus.sourceforge.net/" target="_blank">Notepad++</a>, <a href="http://www.ultraedit.com/" target="_blank">UltraEdit</a>, <a href="http://www.zend.com/fr/products/studio/" target="_blank">Zend Studio</a> ou encore <a href="http://www.eclipse.org/" target="_blank">Eclipse</a>.</p>
<p><span id="more-44"></span></p>
<p>Mon choix s&#8217;est orienté sur <a href="http://www.eclipse.org/" target="_blank">Eclipse</a> pour plusieurs raisons :</p>
<ul>
<li>C&#8217;est un logiciel libre et gratuit. </li>
<li>Il est extensible, universel et polyvalent. Vous pouvez l&#8217;utiliser aussi bien pour faire du <a href="http://fr.wikipedia.org/wiki/Java_(technologie)" target="_blank">java</a>, du <a href="http://fr.wikipedia.org/wiki/C_(langage)" target="_blank">C</a> ou du <a href="http://fr.wikipedia.org/wiki/Php" target="_blank">PHP</a>, ce qui permet donc de pouvoir développer avec plusieurs langages sans avoir à maitriser plusieurs outils.</li>
<li>Il est écrit en Java et il est compatible multi-plateforme. (Windows, Mac et Linux).</li>
<li>Il est très complet en fonctionnalités et si vous recherchez une fonction spécifique le système de plugins vous permettra certainement de l&#8217;ajouter.</li>
</ul>
<p><a href="http://notepad-plus.sourceforge.net/" target="_blank">Notepad++</a> et <a href="http://www.ultraedit.com/" target="_blank">UltraEdit</a> sont des éditeurs de texte. Certes se sont des éditeurs avancés qui proposent de la colorisation syntaxique ou des plugins assez sympa, mais pour faire du développement ils restent un peu limités. <a href="http://notepad-plus.sourceforge.net/" target="_blank">Notepad++</a> est néanmoins une très bonne alternative pour remplacer le bon vieux Notepad de <a href="http://www.microsoft.com/fr/fr/" target="_blank">Windows</a> qui ne propose aucune fonctionnalité.</p>
<h2>Installation d&#8217;Eclipse</h2>
<p>Le site d&#8217;Eclipse se trouve à l&#8217;adresse suivante <a href="http://www.eclipse.org/" target="_blank">http://www.eclipse.org</a>. Et la page       de téléchargement est <a href="http://download.eclipse.org/eclipse/downloads/" target="_blank">http://download.eclipse.org/eclipse/downloads/</a></p>
<p>Pour des problèmes de compatibilité du plugins php, je vous conseille de télécharger et installer la version 3.3 ou antérieur d&#8217;Eclipse. Courant septembre une nouvelle version du plugins devrait être disponible et fonctionnelle avec la version 3.4 d&#8217;Eclipse. <em>Wait and see &#8230;</em></p>
<p>Il est nécessaire d&#8217;installer un java JDK version au moins (5.x) que l&#8217;on peut trouver sur le site de sun: <a href="http://java.sun.com/javase/downloads/index.jsp" target="_blank">http://java.sun.com</a>.</p>
<p>Une fois les packages téléchargés vous n&#8217;avez plus qu&#8217;à décompresser l&#8217;archive d&#8217;Eclipse et à installer le JDK de sun. Faites vous un raccourci d&#8217;eclipse.exe sur votre bureau et exécutez le pour voir si tout fonctionne. Pensez à bien choisir votre dossier (workspace) de travail lors du lancement d&#8217;<a href="http://www.eclipse.org/" target="_blank">Eclipse</a>, celui ci vous permettra d&#8217;y placer vos projets<a href="http://www.eclipse.org/" target="_blank">.<br />
 </a></p>
<h2>Mise en place des plugins</h2>
<p>Une fois <a href="http://www.eclipse.org/" target="_blank">Eclipse</a> fonctionnel, il ne reste plus qu&#8217;à s&#8217;occuper des plugins. On aura principalement besoin des <a href="http://www.eclipse.org/pdt/" target="_blank">PDT</a> (<a href="http://www.eclipse.org/pdt/" target="_blank">PHP Development tools</a>) pour développer en PHP. Ce plugins a un certain nombre de pré-requis. Voici donc la liste des éléments à télécharger:</p>
<ul>
<li><a href="http://www.eclipse.org/pdt/" target="_blank">PDT</a> (<a href="http://download.eclipse.org/tools/pdt/downloads/" target="_blank">PHP Development tools</a>)</li>
<li><a href="http://www.eclipse.org/modeling/mdt/?project=xsd#xsd" target="_blank">XSD</a> (<a href="http://www.eclipse.org/modeling/mdt/downloads/?project=xsd" target="_blank">XML Schema Definition</a>)<a href="http://www.eclipse.org/gef/" target="_blank"></a></li>
<li><a href="http://www.eclipse.org/gef/" target="_blank">GEF</a> (<a href="http://www.eclipse.org/gef/downloads/" target="_blank">Graphical Editing Framework</a>)</li>
<li><a href="http://www.eclipse.org/datatools/" target="_blank">DTP</a> (<a href="http://www.eclipse.org/datatools/downloads.php" target="_blank">Data Tools Platform</a>)</li>
<li><a href="http://www.eclipse.org/webtools/" target="_blank">WTP</a> (<a href="http://download.eclipse.org/webtools/downloads/" target="_blank">Web Tools Platform</a>)</li>
</ul>
<p>Vous pouvez également télécharger le plugin <a href="http://www.xorax.info/blog/news/170-javascript-eclipse-editeur.html" target="_blank">JSEclipse</a> qui était développé par <a href="http://www.interaktonline.com/Products/Eclipse/JSEclipse/Overview/" target="_blank">macromedia</a>. Voici un lien sur mon serveur pour le télécharger: <a href="http://www.nfrey.com/wp-content/uploads/2008/08/jseclipse_plugin_040207.zip" target="_blank">JSEclipse040207</a>.</p>
<p>Une fois les plugins téléchargés, il ne reste plus qu&#8217;à les installer. Il y a deux techniques voir même trois avec la dernière version d&#8217;Eclipse (<em>celle qui ne fonctionne pas avec les PDT 1.0.x</em>). La première consiste à décompresser le contenu de l&#8217;archive du plugin dans le dossier d&#8217;installation d&#8217;Eclipse. La seconde technique est légèrement plus propre. Surtout en cas de désinstallation ou de mis à jour d&#8217;un plugin. Elle consiste à créer un répertoire <em>links </em>et un répertoire <em>myplugins</em> puis de décompresser dans le dossier <em>myplugins</em> l&#8217;archive de votre plugin. Il faudra ensuite créer dans le dossier <em>links </em>un fichier <em>nomduplugins.link</em> avec comme contenu le chemin complet du plugin décompressé dans le répertoire <em>myplugins</em> précédé de <em>path=</em>. Voici un exemple:</p>
<pre><strong><span style="color: #888888;">Contenu du dossier d'installation d'Eclipse</span></strong></pre>
<pre>Eclipse
 |  configuration
 |  features
 |  links
 |  myplugins
 |   |  dtp-sdk_1.5.2
 |   |   |   eclipse
 |   |   |    |  features
 |   |   |    |  plugins
 |   |   |    |  readme
 |   |  org.eclipse.php_feature-R20080603
 |   |   |   eclipse
 |   |  ....
 |  plugins
 |  readme

<strong><span style="color: #888888;">Contenu du dossier links</span></strong>

links
 | dtp.link
 | php.link
 | ...

<strong><span style="color: #888888;">Contenu du fichier php.link</span></strong>
path=E:/dev/Eclipse/myplugins/org.eclipse.php_feature-R20080603

<strong><span style="color: #888888;">Contenu du fichier dtp.link</span></strong>
path=E:/dev/Eclipse/myplugins/dtp-sdk_1.5.2
</pre>
<p>Une fois que tous les plugins sont décompressés et que leurs liens ont été ajoutés dans le dossier <em>links</em> vous pouvez relancer Eclipse. Si tout se passe bien vous devriez avoir une trace des plugins chargés dans Help-&gt;About Eclipse SDK puis en cliquant sur &laquo;&nbsp;Features Details&nbsp;&raquo;.</p>
<div id="attachment_62" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.nfrey.com/wp-content/uploads/2008/08/eclipse_about_features.jpg"><img class="size-medium wp-image-62" title="Eclipse about features" src="http://www.nfrey.com/wp-content/uploads/2008/08/eclipse_about_features-300x190.jpg" alt="Eclipse about features" width="300" height="190" /></a><p class="wp-caption-text">Eclipse about features</p></div>
<p>En cas de problème pour le chargement des plugins, vous pouvez regarder dans le fichier .log qui se trouve dans le dossier <em>.metadata</em> du répertoire workspace d&#8217;Eclipse (emplacement qui vous a été demandé au chargement d&#8217;Eclipse).</p>
<h2>Travailler avec Eclipse</h2>
<p>Une fois Eclipse et ses plugins fonctionnels, il ne reste plus qu&#8217;à savoir comment tout cela fonctionne.</p>
<p>La suite dans un prochain article&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nfrey.com/developpement/eclipse-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuration d&#8217;un environnement de développement (php/mysql)</title>
		<link>http://www.nfrey.com/internet/install_php_mysql/</link>
		<comments>http://www.nfrey.com/internet/install_php_mysql/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 13:39:47 +0000</pubDate>
		<dc:creator>Nicolas Frey</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Serveur]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.nfrey.com/?p=17</guid>
		<description><![CDATA[Comment se configurer un espace de développement PHP/MySQL sous Windows pour travailler proprement et efficacement.]]></description>
			<content:encoded><![CDATA[<p>Développer un site web, beaucoup de monde peut le faire, mais développer proprement et efficacement ce n&#8217;est pas la même affaire.</p>
<p><span id="more-17"></span>Je vais vous expliquer comment vous configurer un environnement de développement <a href="http://www.php.net/" target="_blank">php</a> / <a href="http://www.mysql.fr/" target="_blank">MySQL</a> sous <a href="http://www.microsoft.fr" target="_blank">Windows</a>.</p>
<p>La première chose à faire, c&#8217;est l&#8217;installation des serveurs. Dans notre cas <a href="http://www.mysql.fr/" target="_blank">MySQL</a> et <a href="http://www.apachefrance.com/" target="_blank">Apache</a>. Sur un serveur de production, il faudrait installer séparément apache, php et mysql pour avoir une configuration optimale, mais comme on veut se faire un espace de développement, il existe des solutions comprenant l&#8217;ensemble des applications nécessaires (<a href="http://www.wampserver.com/" target="_blank">wamp</a>, <a href="http://www.easyphp.org/" target="_blank">easyphp</a>, <a href="http://www.apachefriends.org/fr/xampp.html" target="_blank">xampp</a>&#8230;).</p>
<p>Personnellement j&#8217;utilise wamp. Pourquoi:</p>
<ul>
<li>Son interface conviviale et sa simplicité d&#8217;utilisation (Accès rapide aux fichiers de conf, démarrage des services simplifiées &#8230;) </li>
<li>Des addons, qui permettent d&#8217;avoir plusieurs versions possibles et de pouvoir passer de l&#8217;une à l&#8217;autre facilement</li>
</ul>
<p>Quel est l&#8217;intérêt de configurer sur sa machine locale un serveur web et mettre en place un <a href="http://en.wikipedia.org/wiki/Virtual_hosting" target="_blank">virtualHost</a> ?</p>
<ul>
<li>Un dossier, une configuration, des fichiers logs différents pour chaque site.</li>
<li>Une racine et une configuration étant celle du serveur.</li>
<li>Une url (nom local) accessible rapidement pour chaque site développé. <em>ex: www.monsite.com et www.monsite.local</em></li>
<li>Un développement en local permet de ne pas casser son site visible depuis internet. On peut donc faire tout changement sans porter atteinte à la visibilité du site. </li>
<li>Permet aussi de configurer son serveur local pour avoir un meilleur débogage. </li>
</ul>
<p>Si vous êtes convaincu, <a href="http://www.wampserver.com/" target="_blank">Téléchargez wamp</a> et installez-le. Une fois l&#8217;installation effectuée, il faut configurer l&#8217;ensemble. Le but du jeu est d&#8217;avoir chaque site web dans un dossier avec une <a href="http://fr.wikipedia.org/wiki/Uniform_Resource_Locator" target="_blank">URL</a> locale (<a href="http://fr.wikipedia.org/wiki/Domain_Name_System" target="_blank">DNS</a>) lui étant associée. On va donc commencer par modifier le fichier hosts en associant une <a href="http://fr.wikipedia.org/wiki/Adresse_IP" target="_blank">IP</a> à un nom. Ceci permettra d&#8217;accéder à notre machine via un nom plutôt que par une IP, ce qui permettra ensuite de configurer le serveur web sur ce nom.</p>
<p><strong>C:\WINDOWS\system32\drivers\etc\hosts</strong></p>
<pre># fichier hosts</pre>
<pre>127.0.0.1       	localhost # ligne par défaut</pre>
<pre>127.0.0.1		monsite.local # ligne à ajouter.</pre>
<p>Une fois le fichier hosts modifié, on va changer la configuration d&#8217;apache, et ajouter un <a href="http://en.wikipedia.org/wiki/Virtual_hosting" target="_blank">virtualHost</a> sur le nom local de la machine. Un <a href="http://en.wikipedia.org/wiki/Virtual_hosting" target="_blank">virtualHost</a> est une zone qui est mappée sur un nom de domaine. On peut donc avoir sur la même machine avec une seule <a href="http://fr.wikipedia.org/wiki/Adresse_IP" target="_blank">IP</a> plusieurs site web avec chacun un domaine différent.</p>
<p><strong>%install_dir_wamp%/bin/apache/apacheX.X.XX/conf/httpd.conf</strong></p>
<pre>Include conf/httpd-vhosts.conf # A décommenter.</pre>
<p><strong><br />
 %install_dir_wamp%/bin/apache/apacheX.X.XX/conf/httpd-vhosts.conf</strong></p>
<pre>NameVirtualHost * # écoute sur toutes les ip et tous les ports

&lt;VirtualHost *:80&gt;
    ServerName localhost
    DocumentRoot E:/dev/wamp/www # dossier par défaut de wamp
    ErrorLog E:/dev/wamp/logs/error_log # fichier de log
    CustomLog E:/dev/wamp/logs/access_log common # fichier de log
&lt;/VirtualHost&gt;

&lt;VirtualHost *:80&gt;
    ServerName monsite.local # dns que l'on retrouve dans le hosts
    DocumentRoot F:/workspace/monsite # emplacement racine du site
    DirectoryIndex index.php # fichier par défaut
    ErrorLog F:/workspace/monsite/logs/error_log
    CustomLog F:/workspace/monsite/logs/access_log common
&lt;/VirtualHost&gt;
</pre>
<p>Une fois les modifications effectuées, il vous faudra redémarrer le serveur web. N&#8217;oubliez pas de créer tous les dossiers nécessaires (dont les dossiers logs qu&#8217;Apache ne créé pas tout seul) et de passer en ligne Wamp. Si tout se passe bien, le serveur devrait redémarrer correctement et vous dévriez avoir accès via votre navigateur à <a href="http://monsite.local" target="_blank">http://monsite.local</a>. Il ne vous restera plus qu&#8217;à télécharger un <a href="http://fr.wikipedia.org/wiki/Environnement_de_d%C3%A9veloppement_int%C3%A9gr%C3%A9" target="_blank">IDE</a> comme <a href="http://www.eclipse.org/" target="_blank">Eclipse</a>, <a href="http://www.zend.com/fr/products/studio/" target="_blank">Zend Studio</a> ou encore <a href="http://notepad-plus.sourceforge.net" target="_blank">Notepad++</a> pour développer vos sites, installer un système de contrôle de version (versioning) et configurer votre navigateur avec des outils pour simplifier le débogage.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nfrey.com/internet/install_php_mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.751 seconds -->
<!-- Cached page served by WP-Cache -->
