<?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>web2ajax &#187; php</title>
	<atom:link href="http://www.web2ajax.fr/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.web2ajax.fr</link>
	<description>Tout l&#039;actualité du Web2.0 et de l&#039;AJAX</description>
	<lastBuildDate>Fri, 16 Jul 2010 12:29:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<atom:link rel='hub' href='http://www.web2ajax.fr/?pushpress=hub'/>
		<item>
		<title>How to detect visitors language with PHP</title>
		<link>http://www.web2ajax.fr/2010/06/01/how-to-detect-visitors-language-with-php/</link>
		<comments>http://www.web2ajax.fr/2010/06/01/how-to-detect-visitors-language-with-php/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 16:04:55 +0000</pubDate>
		<dc:creator>Guillaume DE LA RUE</dc:creator>
				<category><![CDATA[Accessibilité]]></category>
		<category><![CDATA[Mes travaux]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[autodetect]]></category>
		<category><![CDATA[automatic]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[language]]></category>

		<guid isPermaLink="false">http://www.web2ajax.fr/?p=480</guid>
		<description><![CDATA[I'll show you here how to implement a simple solution to detect and serve content in the visitor language.For this, I use two web domains, one with a '.com' extension and the other in '.fr'But you can either use it as subdomain, like 'fr.website.com' or 'en.website.com'.And third solution, only based on a url param and [...]]]></description>
			<content:encoded><![CDATA[<div class="entry">
<div class="content">I'll show you here how to implement a simple solution to detect and serve content in the visitor language.<br><br>For this, I use two web domains, one with a '.com' extension and the other in '.fr'<br>But you can either use it as subdomain, like 'fr.website.com' or 'en.website.com'.<br>And third solution, only based on a url param and cookies.<br><br>Let me explains more below..<br><br><br>First to see an example : check at www.delarueguillaume.com.<br><br>How to Implement it ?<br>What you need : <br>The first thing we have to do is to detect the visitor language. For this, I'd find a very simple, but efficiently, PHP class named 'Language' ( from Jonas Raoni Soares Silva ). <br><br>Below, this the code to paste in a new file called "LanguageDetect.php", located in your website directory.<br><br>[sourcecode][/sourcecode]<br><br>Auto Detection<br>1/ Now to detect visitor's language, we have to load the LanguageDetect class file, like that :<br>[sourcecode][/sourcecode]<br><br>2/ Set accepted languages : (for me, French or English)<br>[sourcecode][/sourcecode]<br><br>3/ And finally Retrieve best match, which give :<br>[sourcecode][/sourcecode]<br><br>URL Param : $_GET[lang]<br>If the GET 'lang' param is added to url, like 'www.example.com?lang=fr', we overwrite the auto detection value.<br>It's useful to let visitor choose is language by clicking on country flag by example.<br><br>Our code becomes : <br>[sourcecode][/sourcecode]<br><br>Cookie Store and get preferences<br>To avoid to send each time the GET[lang] param, you can use cookies to store language.<br>[sourcecode][/sourcecode]<br><br>Translation File Linking :<br><br>Basics<br>We'll create a file called 'i18n'. This file will contains translations and a function to return translated output.<br>[sourcecode]</div><div class="buttons"></div>
	<div class="clearfix"></div>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.web2ajax.fr/2010/06/01/how-to-detect-visitors-language-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thumb.php v1.1 : Créer des aperçus d&#8217;image très facilement avec GD</title>
		<link>http://www.web2ajax.fr/2010/03/19/creer-des-apercus-dimage-tres-facilement-avec-gd/</link>
		<comments>http://www.web2ajax.fr/2010/03/19/creer-des-apercus-dimage-tres-facilement-avec-gd/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 15:19:07 +0000</pubDate>
		<dc:creator>Guillaume DE LA RUE</dc:creator>
				<category><![CDATA[gd]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[thumb]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[librairie]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://web2ajax.fr/2008/03/02/creer-des-apercus-dimage-tres-facilement-avec-gd/</guid>
		<description><![CDATA[Très utile pour créer une vignette d'une image, voici un script que j'utilise déjà un pti moment : thumb.phpCe script php permet :• Un resize de qualité• Prise en charge de tous les formats d'image reconnus par GD• Mise en cache des images générées• L'image n'est pas resizée si plus petite que les dimensions fixées• [...]]]></description>
			<content:encoded><![CDATA[<div class="entry">
<div class="content">Très utile pour créer une vignette d'une image, voici un script que j'utilise déjà un pti moment : thumb.php<br><br>Ce script php permet :<br><br>• Un resize de qualité<br>• Prise en charge de tous les formats d'image reconnus par GD<br>• Mise en cache des images générées<br>• L'image n'est pas resizée si plus petite que les dimensions fixées<br>• Une manière sûre de ne pas dépasser une dimension fixée<br><br>Voici comment utiliser le script dans votre page HTML :<br><br>[sourcecode]<br>&lt;img src=&quot;thumb.php?i=chemin_image&amp;amp;w=150&amp;amp;h=150&quot;&gt;<br>[/sourcecode]<br><br>i => Chemin de l'image sur le serveur<br>w => Largeur maximale<br>h => Hauteur maximale<br>iar => 0 aspect ratio conserved / 1 picture deformed<br><br>Pour éviter de déformer l'image, je vous conseille d'utiliser dans tous les cas une hauteur égale à la largeur.<br><br>Le script :<br><br>[sourcecode]<br>&lt;?php<br>#@<br>#@ Load a picture and take few parameters<br>#@ Build cache file for thumbnail view<br>#@ <br>#@ Created by Guillaume DE LA RUE &lt;http://web2ajax.fr/&gt;<br>#@ Version 1.1 : 2010/03/19<br>#@<br><br>#@<br>#@ Local Function to get extension<br>#@ <div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content">function _getExtension($file_name) {<br>	$file_infos = pathinfo($file_name);<br>	return '.'.$file_infos['extension'] ;<br>}<br>	<br>#@<br>#@ Config<br>#@ <div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content">$cache_dir = 'tmp/thumbs/' ;<br><br>#@<br>#@ Get url params<br>#@ <div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content">$width 			= (int) $_GET['w'] ;<br>$height			= (int) $_GET['h'] ;<br>$image_file		= $_GET['i'];<br>$image_quality	= (int) $_GET['q'] ;<br>$cache_force	= $_GET['nocache'] ;<br><br>#@<br>#@ Customize the image url<br>#@ <div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content">$image_file = urldecode($image_file) ;<br>$image_file = @reset(@explode('?', $image_file)) ;<br><br>#@<br>#@ Set vars<br>#@ <div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content">$image_file_extension 	= _getExtension($image_file, true) ;<br>$image_file_basename 	= basename($image_file, $image_file_extension) ;	// Filename without extension '.jpg'<br>$thumb_file				= $image_file ;<br><br>#@<br>#@ Infos in image_file<br>#@ <div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content">## Get md5 of files location<br>$thumb_file_md5 = md5($thumb_file).&quot;_&quot;.$width.&quot;_&quot;.$height.&quot;_&quot;.$_GET['iar'] ;<br>$hex_folder = substr($thumb_file_md5, 0, 2).'/' ;<br>$img_thumb = $cache_dir.$hex_folder.$thumb_file_md5.$image_file_extension ;<br><br>// Create a thumb from image<br>function create_thumb($src, $dest, $width = 0, $height = 0, $deform = false, $no_img = './assets/img/trans.gif' ) {<br>	<br>	## Make directory<br>	@mkdir(dirname($dest)) ;<br>	<br>	## Get infos on file with exif<br>	list($width_original, $height_original, $image_mime) = @getimagesize($src);  <br>	<br>	// Init w &amp;amp; h<br>	$_w = ( $width ? $width : $width_original ) ;<br>	$_h = ( $height ? $height : $height_original ) ;<br>	<br>	// If error <br>	if ( ! $image_mime ) {<br>		$src = $no_img ;<br>		list($width_original, $height_original, $image_mime) = getimagesize($src);  <br>	}<br>	<br>	## Detect Portait( =&gt; 0) / paysage ( =&gt; 1)<br>	if ( $width_original &lt;= $height_original ) {<br>		$image_type = 0 ;<br>	} else {<br>		$image_type = 1 ;<br>	}<br>	<br>	## If width or height is empty =&gt; auto<br>	if ( $_w == 0 &amp;amp;&amp;amp; $_h &gt; 0 ) {<br>		$_w = $width_original * ($_h / $height_original ) ;<br>	} else if ( $width &gt; 0 &amp;amp;&amp;amp; $height == 0 ) { <br>		$_h = $height_original * ($_w / $width_original ) ;<br>	} else {<br>		$is_error = true ;<br>	}<br>			<br>	## Define best size to thumb depending params<br>	if ( $image_type == 0 ) {<br>		$best_height 	= $_h ;<br>		if ( $height_original ) $best_width 	= (int) ( $width_original * ($_h / $height_original ) ) ;<br>	} else {<br>		$best_width 	= $_w ;<br>		if ( $width_original ) $best_height 	= (int) ( $height_original * ( $_w / $width_original ) ) ;		<br>	}<br>	<br>	## If picture is little than wanted =&gt; don't stretch it, juste create a standard thumbnail<br>	if ( $width_original &lt; $_w &amp;amp;&amp;amp; $height_original &lt; $_h ) {<br>		$best_width = $width_original ;<br>		$best_height = $height_original ;		<br>	} <br>	<br>	## If 'iar' is setted =&gt; do desired stretching and no more<br>	if ( $deform == &quot;1&quot; ) {<br>		$best_width = (int) $width ;<br>		$best_height = (int) $height ;<br>	}<br>		<br>	// set image type, blending and set functions for gif, jpeg and png  <br>	switch($image_mime){  <br>	  case IMAGETYPE_PNG:  $img = 'png';  $blending = false; break;  <br>	  case IMAGETYPE_GIF:  $img = 'gif';  $blending = true;  break;  <br>	  case IMAGETYPE_JPEG: $img = 'jpeg'; break;  <br>	}  <br>	$imagecreate = &quot;imagecreatefrom$img&quot;;  <br>	$imagesave   = &quot;image$img&quot;;  <br>	<br>	// initialize image from the file  <br>	$image1 = $imagecreate($src);  <br>	<br>	// create a new true color image with dimensions $width2 and $height2  <br>	$image2 = imagecreatetruecolor($best_width, $best_height);  <br>	<br>	// preserve transparency for PNG and GIF images  <br>	if ($img == 'png' || $img == 'gif'){  <br>	  // allocate a color for thumbnail  <br>	  $background = imagecolorallocate($image2, 0, 0, 0);  <br>	  // define a color as transparent  <br>	  imagecolortransparent($image2, $background);  <br>	  // set the blending mode for thumbnail  <br>	  imagealphablending($image2, $blending);  <br>	  // set the flag to save alpha channel  <br>	  imagesavealpha($image2, true);  <br>	}  <br>	<br>	// save thumbnail image to the file  <br>	imagecopyresampled($image2, $image1, 0, 0, 0, 0, $best_width, $best_height, $width_original, $height_original);  <br>	$imagesave($image2, $dest, ($img == 'jpeg' ? 100 : true));  	<br>	ImageDestroy($image2); <br>}<br><br>#@<br>#@ If thumbnail doesn't exists create it !<br>#@ <div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content">if ( ! file_exists($img_thumb) || $cache_force == &quot;true&quot;) <br>	create_thumb($image_file, $img_thumb, $width, $height, $deform = $_GET['iar']) ;<br>else <br><br>// -&gt; Get the type mime of the image<br>list($width_original, $height_original, $image_mime) = getimagesize($img_thumb);  <br>switch($image_mime){  <br>  case IMAGETYPE_PNG:  $image_mime = 'image/png';  break;  <br>  case IMAGETYPE_GIF:  $image_mime = 'image/gif';  break;  <br>  case IMAGETYPE_JPEG: $image_mime = 'image/jpeg'; break;  <br>}  <br><br>#@<br>#@ FORCE TO CACHE IMAGE<br>#@ <div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content"><div class="content">$img_content = file_get_contents($img_thumb) ;<br><br>// not sure if this stuff is really needed, but works:<br>@header(&quot;Cache-Control: private, max-age=10800, pre-check=10800&quot;);<br>@header(&quot;Pragma: private&quot;);<br>@header(&quot;Expires: &quot; . date(DATE_RFC822,strtotime(&quot;+100 day&quot;)));<br>// the browser will send a $_SERVER['HTTP_IF_MODIFIED_SINCE'] <br>// option 1, you can just check if the browser is sendin this<br>if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])){<br>  // if the browser has a cached version of this image, send 304<br>  @header('Last-Modified: '.$_SERVER['HTTP_IF_MODIFIED_SINCE'],true,304);<br>  exit;<br>}<br>// option 2, if you have a file to base your mod date off:<br>if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) <br>       &amp;amp;&amp;amp; <br>  (strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime($img_file))) {<br>  // send the last mod time of the file back<br>  @header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($img_file)).' GMT', <br>  true, 304);<br>  exit;<br>}<br><br>// and here we send the image to the browse with all the stuff<br>// required for tell it to cache<br>$image_infos 	= @getimagesize($cache_dir.$thumb_file_md5.$image_file_extension) ;<br>@header(&quot;Content-type: &quot;.$image_mime); <br>@header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($img_file)) . ' GMT');<br>@header(&quot;Content-Length: &quot;.strlen($img_content));<br>echo $img_content;<br>?&gt;<br>[/sourcecode]</div></div><div class="buttons"></div>
	<div class="clearfix"></div>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.web2ajax.fr/2010/03/19/creer-des-apercus-dimage-tres-facilement-avec-gd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FaceBook Like &#8211; jQuery and autosuggest Search Engine</title>
		<link>http://www.web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-engine/</link>
		<comments>http://www.web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-engine/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 16:29:33 +0000</pubDate>
		<dc:creator>Guillaume DE LA RUE</dc:creator>
				<category><![CDATA[Css]]></category>
		<category><![CDATA[Mes travaux]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web2.0]]></category>
		<category><![CDATA[autosuggest]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[search engine]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[autocomplete jquery]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-engine/</guid>
		<description><![CDATA[FaceBook Autosuggest Like is a powerful jQuery plugin to transform an input field into a real time autocompletion search engine, designed like facebook one.This plugin require jQuery libs and the autocompletion plugin 'Bsn Autosuggest".On custom side, make an ajax request and build search plugins to categorize your results.Features : - Autocomplete and ajax support - [...]]]></description>
			<content:encoded><![CDATA[<div class="entry"><div class='post-thumbnail' ><a href='http://www.web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-engine/' title='Permanent link to FaceBook Like &#8211; jQuery and autosuggest Search Engine'><img src='http://www.web2ajax.fr/thumb.php?i=http://www.web2ajax.fr/wp-content/uploads/2008/02/facebook_searchengine.png&w=200' alt='FaceBook Like &#8211; jQuery and autosuggest Search Engine'  /></a></div>
<div class="content">FaceBook Autosuggest Like is a powerful jQuery plugin to transform an input field into a real time autocompletion search engine, designed like facebook one.<br><br>This plugin require jQuery libs and the autocompletion plugin 'Bsn Autosuggest".<br><br>On custom side, make an ajax request and build search plugins to categorize your results.<br><br>Features : <br>- Autocomplete and ajax support <br>- Database search <br>- Support search plugins <br>- Support cache <br>- Cross Browser support ( IE > 5.5, FireFox, Safari, Opera ) <br><br>I let u see the demo...<br>Have Fun !</div></div><div class="buttons"><div class="go_demo"><a href="http://www.web2ajax.fr/examples/facebook_searchengine/" target="_blank" title="Link to demo page of FaceBook Like &#8211; jQuery and autosuggest Search Engine"><img src="https://s3.amazonaws.com/web2ajax/Web2ajax_v2/img/button_demo.png" width="198" height="60"></a></div></div>
	<div class="clearfix"></div>

<p>Related posts:<ol><li>&nbsp;<a href='http://www.web2ajax.fr/2010/03/05/genius-menu-jquery-plugin-like-macos-dock-menu-effect/' rel='bookmark' title='Permanent Link: Genius Menu &#8211; jQuery plugin Like MacOS Dock Menu Effect'>Genius Menu &#8211; jQuery plugin Like MacOS Dock Menu Effect</a></li>
<li>&nbsp;<a href='http://www.web2ajax.fr/2008/04/16/inserez-des-indicateurs-de-chargement-directement-en-javascript/' rel='bookmark' title='Permanent Link: Insérez des indicateurs de chargement directement en JavaScript !!'>Insérez des indicateurs de chargement directement en JavaScript !!</a></li>
<li>&nbsp;<a href='http://www.web2ajax.fr/2007/09/26/jquery-edit-in-place-plugin/' rel='bookmark' title='Permanent Link: jQuery : Edit in place plugin'>jQuery : Edit in place plugin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-engine/feed/</wfw:commentRss>
		<slash:comments>168</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.291 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-29 23:12:23 -->
