<?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>My bag of tricks</title>
	<atom:link href="http://bramas.fr/blog/lang/en/feed/" rel="self" type="application/rss+xml" />
	<link>http://bramas.fr/blog</link>
	<description>not just another bag</description>
	<lastBuildDate>Tue, 04 Oct 2011 18:53:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<meta name="generator" content="Newspress-Sample 2.0.3" />
		<item>
		<title>Utiliser Google Analytics Export Api</title>
		<link>http://bramas.fr/blog/lang/en/2011/10/04/utiliser-google-analytics-export-api</link>
		<comments>http://bramas.fr/blog/lang/en/2011/10/04/utiliser-google-analytics-export-api#comments</comments>
		<pubDate>Tue, 04 Oct 2011 17:11:44 +0000</pubDate>
		<dc:creator>Quentin</dc:creator>
				<category><![CDATA[home featured]]></category>

		<guid isPermaLink="false">http://bramas.fr/blog/?p=212</guid>
		<description><![CDATA[Dans cet article je vous propose une solution pour récupérer le nombre de visiteurs d&#8217;un de vos site tracé par google analytics. Cela deux étapes : Authentification : utilisant la &#8230;<a class="continue_reading_link" href="http://bramas.fr/blog/lang/en/2011/10/04/utiliser-google-analytics-export-api">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Dans cet article je vous propose une solution pour récupérer le nombre de visiteurs d&#8217;un de vos site tracé par google analytics. Cela deux étapes :</p>
<ol>
<li>Authentification : utilisant la méthode ClientLogin avec votre email et mot de passe de votre compte  google pour récupérer un auth token</li>
<li>Requête : utilisant le auth token.</li>
</ol>
<h2>Authentification</h2>
<pre class="brush: php;">$url = 'https://www.google.com/accounts/ClientLogin';
$fields = array(
 'accountType'=&#62;urlencode('GOOGLE'),
 'Email'=&#62;urlencode('YOUR EMAIL'),
 'Passwd'=&#62;urlencode('YOUR PASSWORD'),
 'service'=&#62;urlencode(&#34;analytics&#34;),
 'source'=&#62;urlencode('GROUP NAME-APP NAME-VERSION')
 );

$fields_string='';
foreach($fields as $key=&#62;$value) { $fields_string .= $key.'='.$value.'&#38;'; }
rtrim($fields_string,'&#38;');

$ch = curl_init();
// utile pour les problème de ssl (mais pas parfait niveau sécurité)
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

if(($result = curl_exec($ch))===false)
{
 curl_close($ch);
 exit('Curl Error: '.curl_error($ch));
}
curl_close($ch);

echo $result;
/*
de la form &#34;**********************\n Auth=********&#34;
*/
</pre>
<p>Il faut récupérer la variable Auth Si vous ne savez pas comment :</p>
<pre class="brush: php;">

if(strpos($result,&#34;\n&#34;)!==false)
{
  $results=array();
  $result=explode(&#34;\n&#34;,$result);
  foreach($result as $r)
  {
    if(strpos($r,'=')===false)
    {
      continue;
    }
    $temp = explode('=',$r,2);
    $results[$temp[0]] = $temp[1];

  }

}
$auth = $results['Auth'];
</pre>
<h2>Requête</h2>
<p>ensuite on peut faire les requêtes qu&#8217;on veut. Un exemple simple : le nombre de visiteurs depuis le début du mois:</p>
<pre class="brush: php;">&#60;/pre&#62;
$url = 'https://www.google.com/analytics/feeds/data?'.
'ids=SITE ID exemple : ga:12345&#38;metrics=ga:visits&#38;start-date='.$first_day_of_last_month.'&#38;end-date='.$last_day_of_last_month.'&#38;v=2';

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HTTPHEADER,
array( &#34;GData-Version: 2&#34;,
'Authorization: GoogleLogin auth='.$_SESSION['ga']['auth']
));
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
if(($result = curl_exec($ch))===false)
{
curl_close($ch);
exit('Curl Error: '.curl_error($ch));
}
curl_close($ch);

echo $result; // xml </pre>
<p>On peut traiter facilement le résultat, par exemple dans notre cas :</p>
<pre class="brush: php;">
$doc = new DOMDocument();

$doc-&#62;loadXML(request($params));

$metrics = $doc-&#62;getElementsByTagName('metric')-&#62;item(0)-&#62;getAttribute('value');

echo 'Visiteurs : '.$metrics;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bramas.fr/blog/lang/en/2011/10/04/utiliser-google-analytics-export-api/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Javascript] quelques astuce de compatibilité</title>
		<link>http://bramas.fr/blog/lang/en/2011/04/12/javascript-quelques-astuce-de-compatibilite</link>
		<comments>http://bramas.fr/blog/lang/en/2011/04/12/javascript-quelques-astuce-de-compatibilite#comments</comments>
		<pubDate>Tue, 12 Apr 2011 07:48:55 +0000</pubDate>
		<dc:creator>Quentin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[backgroudPosition]]></category>
		<category><![CDATA[background-position-x]]></category>
		<category><![CDATA[background-position-y]]></category>
		<category><![CDATA[backgroundPositionX]]></category>
		<category><![CDATA[backgroundPositionY]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://bramas.fr/blog/?p=203</guid>
		<description><![CDATA[Accéder à la fenêtre parent avec Opéra Un petit truc à ce rappeler sur Opéra : lorsqu&#8217;un script ce trouve dans une iframe veut appeler une fonction qui se situe &#8230;<a class="continue_reading_link" href="http://bramas.fr/blog/lang/en/2011/04/12/javascript-quelques-astuce-de-compatibilite">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Accéder à la fenêtre parent avec Opéra</h2>
<p>Un petit truc à ce rappeler sur Opéra : lorsqu&#8217;un script ce trouve dans une iframe veut appeler une fonction qui se situe dans la fenêtre parent : parent.foo(); la fonction foo() doit obligatoirement se trouver dans le &#60;head&#62; sinon l&#8217;appel echoue.</p>
<h2>iframe Cross Domain et cookie de session</h2>
<p>Si vos utilisateur sont logué sur un site hébergé sur un serveur A, lorsqu&#8217;une page d&#8217;un serveur B insert une iframe du site A, l&#8217;iframe n&#8217;a pas accés au cookie de session, l&#8217;utilisateur n&#8217;est donc pas logué, et parfois même cela réinitialise la session sur le serveur A. Une technique simple consiste a passé par une page intermédiaire i.php.</p>
<p>fenetreSurB.php</p>
<pre class="brush: xml;">

&#60;body&#62;
&#60;iframe src=&#34;http://A/i.php?page=pageSurA.php&#34;&#62;&#60;/iframe&#62;
&#60;/body&#62;
</pre>
<p>i.php</p>
<pre class="brush: xml;">

&#60;body&#62;
&#60;div id=&#34;content&#34;&#62;
&#60;/div&#62;
&#60;script type=&#34;text/javascript&#34;&#62;
$.post(&#34;http://A/&#60;?php echo $_GET['page'];  ?&#62;&#34;,
function(d)
{
$('#content').html(d);
});
&#60;/script&#62;
&#60;/body&#62;
</pre>
<p>voilà , ainsi l&#8217;utilisateur apparaît comme connecté dans l&#8217;iframe.</p>
<h2>plugin jQuery backgroundPosition + hack Opéra</h2>
<p>Le plugin <a title="plugin jquery background position" href="http://plugins.jquery.com/project/backgroundPosition-Effect">http://plugins.jquery.com/project/backgroundPosition-Effect</a> permet d&#8217;animer correctement backgroundPosition dans jQuery. Mais dans Opéra qui ne connait pas background-position-x et background-position-y, l&#8217;animation d&#8217;un des deux composantes reste impossible d&#8217;où une version modifier du plugin que l&#8217;on utilise de la façon suivante :</p>
<pre class="brush: jscript;">

$('.element').animate({backgroundPosition: 'initial 40px'},'fast');
// anime baground-position-y jusqu'a 40px

$('.element').animate({backgroundPosition: '40px initial'},'fast');
// anime baground-position-x jusqu'a 40px
</pre>
<pre class="brush: jscript;">

/**
 * @author Alexander Farkas
 * v. 1.21
 */

(function($) {
 if(!document.defaultView &#124;&#124; !document.defaultView.getComputedStyle){ // IE6-IE8
 var oldCurCSS = jQuery.curCSS;
 jQuery.curCSS = function(elem, name, force){
 if(name === 'background-position'){
 name = 'backgroundPosition';
 }
 if(name === 'background-position-x'){
 name = 'backgroundPositionX';
 }
 if(name === 'background-position-y'){
 name = 'backgroundPositionY';
 }
 if((name !== 'backgroundPosition')  &#124;&#124; !elem.currentStyle &#124;&#124; elem.currentStyle[ name ]){
 return oldCurCSS.apply(this, arguments);
 }
 var style = elem.style;
 if ( !force &#38;&#38; style &#38;&#38; style[ name ] ){
 return style[ name ];
 }
 return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
 };
 }

 var oldAnim = $.fn.animate;
 $.fn.animate = function(prop){
 if('background-position' in prop){
 prop.backgroundPosition = prop['background-position'];
 delete prop['background-position'];
 }
 if('backgroundPosition' in prop){
 prop.backgroundPosition = '('+ prop.backgroundPosition;
 }
 if('background-position-y' in prop){
 prop.backgroundPositionY = prop['background-position-y'];
 delete prop['background-position-y'];
 }
 if('backgroundPositionY' in prop){
 prop.backgroundPositionY = '('+ prop.backgroundPositionY;
 }
 if('background-position-x' in prop){
 prop.backgroundPositionX = prop['background-position-x'];
 delete prop['background-position-x'];
 }
 if('backgroundPositionX' in prop){
 prop.backgroundPositionX = '('+ prop.backgroundPositionX;
 }

 return oldAnim.apply(this, arguments);
 };

 function toArray(strg){
 strg = strg.replace(/left&#124;top/g,'0px');
 strg = strg.replace(/right&#124;bottom/g,'100%');
 strg = strg.replace(/([0-9\.]+)(\s&#124;\)&#124;$)/g,&#34;$1px$2&#34;);
 var res = strg.match(/(-?[0-9\.]+)(px&#124;\%&#124;em&#124;pt)\s(-?[0-9\.]+)(px&#124;\%&#124;em&#124;pt)/);
 return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
 }

 $.fx.step. backgroundPosition = function(fx) {
 if (!fx.bgPosReady) {
 var start = $.curCSS(fx.elem,'backgroundPosition');

 if(!start){//FF2 no inline-style fallback
 start = '0px 0px';
 }
 start = toArray(start);

 fx.start = [start[0],start[2]];

 var res = fx.options.curAnim.backgroundPosition.match(/([0-9\-\.a-z\%A-Z]+) ([0-9\-\.a-z\%A-Z]+)/);

 var initial=[res[1]=='initial', res[2]=='initial'];

 fx.isInitalValue=initial;

 fx.options.curAnim.backgroundPosition=fx.options.curAnim.backgroundPosition.replace('initial','0px');
 var end = toArray(fx.options.curAnim.backgroundPosition);
 fx.end = [initial[0]?start[0]:end[0],initial[1]?start[2]:end[2]];

 fx.unit = [initial[0]?start[1]:end[1],initial[1]?start[3]:end[3]];
 fx.bgPosReady = true;
 }
var nowPosX = [];
 nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
 nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
 fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

 };

})(jQuery);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bramas.fr/blog/lang/en/2011/04/12/javascript-quelques-astuce-de-compatibilite/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install the Symfony framework on Windows</title>
		<link>http://bramas.fr/blog/lang/en/2011/04/12/installer-le-framework-symfony-sur-windowsinstall-the-symfony-framework-on-windows</link>
		<comments>http://bramas.fr/blog/lang/en/2011/04/12/installer-le-framework-symfony-sur-windowsinstall-the-symfony-framework-on-windows#comments</comments>
		<pubDate>Tue, 12 Apr 2011 07:16:59 +0000</pubDate>
		<dc:creator>Quentin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://bramas.fr/?p=110</guid>
		<description><![CDATA[Symfony est un framework php de développement de site web.Comme d&#8217;autres, notamment cakePHP, il permet de facilité le développement de site web, et offre des outils puissants (Debug, &#8230;) Je &#8230;<a class="continue_reading_link" href="http://bramas.fr/blog/lang/en/2011/04/12/installer-le-framework-symfony-sur-windowsinstall-the-symfony-framework-on-windows">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Symfony est un framework php de développement de site web.Comme d&#8217;autres, notamment cakePHP, il permet de facilité le développement de site web, et offre des outils puissants (Debug, &#8230;)</p>
<p>Je m&#8217;intéresse a ce framework car il est open source, très suivie, et qu&#8217;il est très puissants (le site du zero et dailymotion l&#8217;utilisent) .</p>
<p>Il y a un chose qui est assez nouvelle (surtout pour les utilisateur de windows) c&#8217;est l&#8217;utilisation de ligne de commande pour effectuer des tache, qu&#8217;on a donc plus a faire a la main <img src='http://bramas.fr/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . Le problème pour ceux qui on pas l&#8217;habitude de l&#8217;utilisé, c&#8217;est qu&#8217;il faut faire en sorte qu&#8217;elle marche, et qu&#8217;elle sorte la même chose que sur les tutoriels, et pas &#8220;symfony n&#8217;est pas reconnue en tant que commande int&#8230;&#8221;, voici donc comment s&#8217;y prendre.</p>
<p>Tout d&#8217;abord il faut avoir un serveur local installé.</p>
<p>-Télécharger le dernière version stable de Symfony.</p>
<p>-Repéré ou ce trouve le fichier php.exe.<br />
Pour cela faite une recherche dans le dossier d&#8217;installation de votre serveur local</p>
<p>-Dézipez symfony dans le même dossier que php.exe</p>
]]></content:encoded>
			<wfw:commentRss>http://bramas.fr/blog/lang/en/2011/04/12/installer-le-framework-symfony-sur-windowsinstall-the-symfony-framework-on-windows/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[cakephp] upload images component</title>
		<link>http://bramas.fr/blog/lang/en/2010/12/12/cakephp-composant-dupload-dimagescakephp-upload-images-components</link>
		<comments>http://bramas.fr/blog/lang/en/2010/12/12/cakephp-composant-dupload-dimagescakephp-upload-images-components#comments</comments>
		<pubDate>Sun, 12 Dec 2010 11:59:09 +0000</pubDate>
		<dc:creator>Quentin</dc:creator>
				<category><![CDATA[cakePhp]]></category>
		<category><![CDATA[home featured]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://bramas.fr/blog/?p=157</guid>
		<description><![CDATA[Voici un petit composant que j&#8217;ai créé afin d&#8217;uploader des images facilements dans cakePhp. Il permet en quelques ligne de décider quelles tailles d&#8217; images on veut et dans quels &#8230;<a class="continue_reading_link" href="http://bramas.fr/blog/lang/en/2010/12/12/cakephp-composant-dupload-dimagescakephp-upload-images-components">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Voici un petit composant que j&#8217;ai créé afin d&#8217;uploader des images facilements dans cakePhp. Il permet en quelques ligne de décider quelles tailles d&#8217; images on veut et dans quels dossier en lui donnant en paramètre des options très simple comme :</p>
<pre class="brush: php;">
$option = array(0 =&#62; array('folder'=&#62;'',
 'width'=&#62; 1600,
 'height'=&#62; 1600),
 1 =&#62; array('folder'=&#62;'thumb',
 'size'=&#62; '210x310',
 'crop' =&#62; true));</pre>
<p><span id="more-157"></span></p>
<p>voici le code source du composant. Il a été inspiré d&#8217;un petit composant d&#8217;upload d&#8217;image simple.</p>
<pre class="brush: php;">

&#60;?php
/*
 File: /app/controllers/components/QBimage.php
*/
class ImageComponent extends Object
{
 /*
 *    Uploads an images with options : images with max size, cropped images with max height and width.
 *   each image can be put on different folder
 *     Directions:
 *    In view where you upload the image, make sure your form creation is similar to the following
 *    &#60;?= $form-&#62;create('FurnitureSet',array('type' =&#62; 'file')); ?&#62;
 *
 *    In view where you upload the image, make sure that you have a file input similar to the following
 *    &#60;?= $form-&#62;file('Image/name1'); ?&#62;
 *
 *    In the controller, add the component to your components array
 *    var $components = array(&#34;QBImage&#34;);
 *
 *    In your controller action (the parameters are expained below)
 *    $op = array(0=&#62;array('size'=&#62;1600),
 *               1 =&#62; array('folder'=&#62;'thumb', 'crop'=&#62;true, 'size'=&#62;'250x400'));
 *    $filename = $this-&#62;Image-&#62;upload_images($this-&#62;data,&#34;name1&#34;,&#34;sets&#34;,$op);
 *    this returns the file name of the result image.  You can  store this file name in the database
 *
 *    Note that your image will be stored under the $folderName
 *    Image: /webroot/img/$folderName/*
 *
 *    Finally in the view where you want to see the images
 *    &#60;?= $html-&#62;image('sets/big/'.$furnitureSet['FurnitureSet']['image_path']);
 *     where &#34;sets&#34; is the folder name we saved our pictures in, and $furnitureSet['FurnitureSet']['image_path'] is the file name we stored in the database

 *    Parameters:
 *    $data: CakePHP data array from the form
 *    $datakey: key in the $data array. If you used &#60;?= $form-&#62;file('Image/name1'); ?&#62; in your view, then $datakey = name1
 *    $folderName: the name of the root folder
 *    $options: an array with the upload options
 *               $option = array(0 =&#62; array('folder'=&#62;'',
 *                                           'width'=&#62; 1600,
 *                                           'height'=&#62; 1600),
 *                               1 =&#62; array('folder'=&#62;'thumb',
 *                                           'size'=&#62; '210x310',
 *                                           'crop' =&#62; true));
 */

 function upload_images($data, $datakey, $folderName, $options=null) {

 if (strlen($data['Image'][$datakey]['name'])&#62;4){
 $error = 0;

 if(!is_array($options))
 {
 $options=array(0=&#62;array('folder'=&#62;'','height'=&#62;1600));
 }
 if(isset($options[0]) &#38;&#38;  !is_array($options[0]))
 {
 $options=array(0=&#62;$options);
 }else
 if(isset($options[1]) &#38;&#38;  !is_array($options[1]))
 {
 $options=array(0=&#62;$options);
 }

 $tempuploaddir = &#34;img/temp&#34;; // the /temp/ directory, should delete the image after we upload
 $biguploaddir = &#34;img/&#34;.$folderName.&#34;/&#34;; // the /big/ directory
 $smalluploaddir = &#34;img/&#34;.$folderName.&#34;/small/&#34;;

 // Make sure the required directories exist, and create them if necessary
 if(!is_dir($tempuploaddir)) mkdir($tempuploaddir,0777);
 if(!is_dir(&#34;img/&#34;.$folderName)) mkdir(&#34;img/&#34;.$folderName,0777);

 $filetype = $this-&#62;getFileExtension($data['Image'][$datakey]['name']);
 $filetype = strtolower($filetype);

 if (($filetype != &#34;jpeg&#34;)  &#38;&#38; ($filetype != &#34;jpg&#34;) &#38;&#38; ($filetype != &#34;gif&#34;) &#38;&#38; ($filetype != &#34;png&#34;))
 {
 // verify the extension
 echo 'Mauvaise extension';
 return false;
 }
 else
 {
 // Get the image size
 $imgsize = GetImageSize($data['Image'][$datakey]['tmp_name']);
 }

 // Generate a unique name for the image (from the timestamp)
 $id_unic = str_replace(&#34;.&#34;, &#34;&#34;, strtotime (&#34;now&#34;));
 $filename = $id_unic;

 settype($filename,&#34;string&#34;);
 $filename.= &#34;.&#34;;
 $filename.=$filetype;
 $tempfile = $tempuploaddir . &#34;/$filename&#34;;

 if (is_file($data['Image'][$datakey]['tmp_name']) &#124;&#124; is_uploaded_file($data['Image'][$datakey]['tmp_name']))
 {
 // Copy the image into the temporary directory
 if (!copy($data['Image'][$datakey]['tmp_name'],&#34;$tempfile&#34;))
 {
 print &#34;Error Uploading File!.&#34;;
 exit();
 }
 else {
 /*
 *    Generate the big version of the image with max of $imgscale in either directions
 */

 foreach($options as $op)
 {
 if(empty($op['height']))
 {
 if(empty($op['width']))
 {
 if(empty($op['size']))
 {
 $op['height']=$op['width']=1600;
 }
 else
 {
 if(is_numeric($op['size']))
 {
 $op['height']=$op['width']=$op['size'];
 }
 else
 {
 list($op['width'],$op['height']) = explode('x',$op['size']);
 }
 }
 }
 else{
 $op['height']=$op['width'];
 }
 }
 if(empty($op['width']))
 {
 $op['width']=$op['height'];
 }
 if(empty($op['folder']))
 {
 $op['folder']='';
 }
 if(empty($op['crop']))
 {
 $op['crop']=false;
 }
 $op['_filename'] = $filename;
 $op['_foldername'] = &#34;img/&#34;.$folderName.&#34;/&#34;;

 if(!$op['crop'])
 {
 if(!$this-&#62;resize_img($tempfile, $op))
 {
 return false;
 }
 }
 else{
 if(!$this-&#62;crop_but_keep_ratio($tempfile, $op))
 {
 return false;
 }
 }
 }

 // Delete the temporary image
 unlink($tempfile);
 }

 }
 else
 return false;
 // Image uploaded, return the file name
 return $filename;
 }
 }

 function crop_but_keep_ratio($imgname, $op) {

 $fixeWidth = $op['width'];
 $fixeHeight = $op['height'];
 $filename = $op['_foldername'].$op['folder'].'/'.$op['_filename'];

 $filetype = $this-&#62;getFileExtension($imgname);
 $filetype = strtolower($filetype);
echo 'A-';
 switch($filetype){
 case &#34;jpeg&#34;:
 case &#34;jpg&#34;:
 $img_src = ImageCreateFromjpeg ($imgname);
 break;
 case &#34;gif&#34;:
 $img_src = imagecreatefromgif ($imgname);
 break;
 case &#34;png&#34;:
 $img_src = imagecreatefrompng ($imgname);
 break;
 }
 $width = imagesx($img_src);
 $height = imagesy($img_src);
 $fixeRatio = $fixeHeight / $fixeWidth;
 $realRatio = $height / $width;

 if($fixeRatio&#60;$realRatio)// la nouvelle image sera plus étalé que l'ancienne
 {
 $newheight = $fixeWidth*$realRatio;
 $newwidth = $fixeWidth;
 }
 else// la nouvelle image sera plus étalé que l'ancienne
 {
 $newwidth = $fixeHeight/$realRatio;
 $newheight = $fixeHeight;
 }
 //-- Calculate resampling

 //-- Calculate cropping (division by zero)
 $cropx = ($newwidth - $fixeWidth != 0) ? ($newwidth - $fixeWidth) / 2 : 0;
 $cropy = ($newheight - $fixeHeight != 0) ? ($newheight - $fixeHeight) / 2 : 0;

 //-- Setup Resample &#38; Crop buffers
 $resampled = imagecreatetruecolor($newwidth, $newheight);
 $cropped = imagecreatetruecolor($fixeWidth, $fixeHeight);

 //-- Resample
 imagecopyresampled($resampled, $img_src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
 //-- Crop
 imagecopy($cropped, $resampled, 0, 0, $cropx, $cropy, $newwidth, $newheight);

 // Save the cropped image
 switch($filetype)
 {
 case &#34;jpeg&#34;:
 case &#34;jpg&#34;:
 if(!imagejpeg($cropped,$filename,80))
 return false;
 break;
 case &#34;gif&#34;:
 if(!imagegif($cropped,$filename,80))
 return false;
 break;
 case &#34;png&#34;:
 if(!imagepng($cropped,$filename,80))
 return false;
 break;
 }
 return false;

 }

 function resize_img($imgname, $op)    {

 if($op['width']&#62;$op['height'])
 {
 $size = $op['height'];
 }
 else{
 $size = $op['width'];
 }
 $filename = $op['_foldername'].$op['folder'].'/'.$op['_filename'];

 $filetype = $this-&#62;getFileExtension($imgname);
 $filetype = strtolower($filetype);

 switch($filetype) {
 case &#34;jpeg&#34;:
 case &#34;jpg&#34;:
 $img_src = ImageCreateFromjpeg ($imgname) ;
 break;
 case &#34;gif&#34;:
 $img_src = imagecreatefromgif ($imgname);
 break;
 case &#34;png&#34;:
 $img_src = imagecreatefrompng ($imgname);
 break;
 }
 //  if(empty($img_src)) return false;

 $true_width = imagesx($img_src);
 $true_height = imagesy($img_src);

 if ($true_width&#62;=$true_height)
 {
 $width=$size;
 $height = ($width/$true_width)*$true_height;
 }
 else
 {
 $width=$size;
 $height = ($width/$true_width)*$true_height;
 }
 $img_des = ImageCreateTrueColor($width,$height);
 imagecopyresampled ($img_des, $img_src, 0, 0, 0, 0, $width, $height, $true_width, $true_height);

 // Save the resized image
 switch($filetype)
 {
 case &#34;jpeg&#34;:
 case &#34;jpg&#34;:
 imagejpeg($img_des,$filename,80);
 break;
 case &#34;gif&#34;:
 imagegif($img_des,$filename,80);
 break;
 case &#34;png&#34;:
 imagepng($img_des,$filename,9);
 break;
 }
 return true;
 }

 function getFileExtension($str) {

 $i = strrpos($str,&#34;.&#34;);
 if (!$i) { return &#34;&#34;; }
 $l = strlen($str) - $i;
 $ext = substr($str,$i+1,$l);
 return $ext;
 }
} ?&#62;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bramas.fr/blog/lang/en/2010/12/12/cakephp-composant-dupload-dimagescakephp-upload-images-components/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirection of the Whole Url with UrlReWriting</title>
		<link>http://bramas.fr/blog/lang/en/2010/10/15/redirection-de-lensemble-de-ladresse-avec-urlrewritingredirection-of-the-whole-url-with-urlrewriting</link>
		<comments>http://bramas.fr/blog/lang/en/2010/10/15/redirection-de-lensemble-de-ladresse-avec-urlrewritingredirection-of-the-whole-url-with-urlrewriting#comments</comments>
		<pubDate>Fri, 15 Oct 2010 00:01:25 +0000</pubDate>
		<dc:creator>Quentin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://bramas.fr/blog/?p=152</guid>
		<description><![CDATA[Voici une astuce pour redirigé tout un domaine vers un autre en utilisant le module UrlReWriting dans un fichier .htaccess. exemple : on veut rediriger tout ce qui pointe sur &#8230;<a class="continue_reading_link" href="http://bramas.fr/blog/lang/en/2010/10/15/redirection-de-lensemble-de-ladresse-avec-urlrewritingredirection-of-the-whole-url-with-urlrewriting">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Voici une astuce pour redirigé tout un domaine vers un autre en utilisant le module UrlReWriting dans un fichier .htaccess.</p>
<p>exemple : on veut rediriger tout ce qui pointe sur www.monsite.fr vers monsite.fr</p>
<p>Une simple page de redirection ne suffirait pas a rediriger un lien comme<br />
www.monsite.fr/news/sports?until=20-10-2009<br />
vers : monsite.fr/news/sports?until=20-10-2009</p>
<p>il faut donc tout recupérer et ensuite redirigé :</p>
<p>www/httpdocs/.htaccess</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">   RewriteEngine on
   RewriteBase /
   RewriteRule    (.*) redir.php?$1 [QSA,L]</pre></div></div>

<p>www/httpdocs/redir.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;</pre></div></div>

<p>1){  $page .= $a.&#8217;&#38;&#8217;;  }  $i++; } header(&#8216;Location: &#8216;.$page); ?&#62;</p>
]]></content:encoded>
			<wfw:commentRss>http://bramas.fr/blog/lang/en/2010/10/15/redirection-de-lensemble-de-ladresse-avec-urlrewritingredirection-of-the-whole-url-with-urlrewriting/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NoScale for full flash website</title>
		<link>http://bramas.fr/blog/lang/en/2010/05/17/noscale-pour-des-site-entierement-en-flashnoscale-for-full-flash-website</link>
		<comments>http://bramas.fr/blog/lang/en/2010/05/17/noscale-pour-des-site-entierement-en-flashnoscale-for-full-flash-website#comments</comments>
		<pubDate>Mon, 17 May 2010 18:26:04 +0000</pubDate>
		<dc:creator>Quentin</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://bramas.fr/?p=137</guid>
		<description><![CDATA[How configure it: Comment le configurer: stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.BOTTOM; StageAlign.TOP Top Center StageAlign.BOTTOM Bottom Center StageAlign.LEFT Center Left StageAlign.RIGHT Center Right StageAlign.TOP_LEFT Top Left StageAlign.TOP_RIGHT Top Right &#8230;<a class="continue_reading_link" href="http://bramas.fr/blog/lang/en/2010/05/17/noscale-pour-des-site-entierement-en-flashnoscale-for-full-flash-website">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span lang="en">How configure it: </span><span lang="fr">Comment le configurer:</span></p>
<p><span lang="fr"><span id="more-137"></span><br />
</span></p>
<pre class="brush: php;">
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.BOTTOM;
</pre>
<table>
<tbody>
<tr>
<td>StageAlign.TOP</td>
<td>Top</td>
<td>Center</td>
</tr>
<tr>
<td>StageAlign.BOTTOM</td>
<td>Bottom</td>
<td>Center</td>
</tr>
<tr>
<td>StageAlign.LEFT</td>
<td>Center</td>
<td>Left</td>
</tr>
<tr>
<td>StageAlign.RIGHT</td>
<td>Center</td>
<td>Right</td>
</tr>
<tr>
<td>StageAlign.TOP_LEFT</td>
<td>Top</td>
<td>Left</td>
</tr>
<tr>
<td>StageAlign.TOP_RIGHT</td>
<td>Top</td>
<td>Right</td>
</tr>
<tr>
<td>StageAlign.BOTTOM_LEFT</td>
<td>Bottom</td>
<td>Left</td>
</tr>
<tr>
<td>StageAlign.BOTTOM_RIGHT</p>
<p>Nothing</td>
<td>Bottom</p>
<p>Center</td>
<td>Right</p>
<p>Center</td>
</tr>
</tbody>
</table>
<p><span lang="fr">De plus il faut remplacé les valeurs width et height à 100% partout dans le fichier .html où est intégré le .swf.</span><span lang="en"> Moreover you have to replace all width and height value to &#8220;100%&#8221; in the .html file.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://bramas.fr/blog/lang/en/2010/05/17/noscale-pour-des-site-entierement-en-flashnoscale-for-full-flash-website/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ultratools &#8211; Editor</title>
		<link>http://bramas.fr/blog/lang/en/2010/05/07/ultratools-editor</link>
		<comments>http://bramas.fr/blog/lang/en/2010/05/07/ultratools-editor#comments</comments>
		<pubDate>Fri, 07 May 2010 13:00:18 +0000</pubDate>
		<dc:creator>Quentin</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Freeware]]></category>
		<category><![CDATA[home featured]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://bramas.fr/?p=132</guid>
		<description><![CDATA[UltraStar Deluxe is a free and open source karaoke game inspired by the Singstar™ game available on the Playstation®. It allows up to six players to sing along with music &#8230;<a class="continue_reading_link" href="http://bramas.fr/blog/lang/en/2010/05/07/ultratools-editor">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span lang="en"><a href="http://ultrastardx.sourceforge.net/" target="_blank">UltraStar Deluxe</a> is a free and open source karaoke game inspired by the Singstar™ game available on the Playstation®. It allows up to six players to sing along with music using microphones in order to score points, depending on the pitch of the voice and the rhythm of singing. </span></p>
<p><span lang="en"><a href="http://www.ultratools.org" target="_blank">Ultratools &#8211; Editor</a> is a open source editor for ultrastar songs. you can edit song intuitively and create song very easily!!</span></p>
<p><span lang="en">If you want to contribute to the project you are welcome!!</span></p>
<p><span lang="en"><a href="http://www.ultratools.org/" target="_blank">Official website</a></span></p>
<p>Playstation®</p>



<p><span lang="en"> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://bramas.fr/blog/lang/en/2010/05/07/ultratools-editor/feed</wfw:commentRss>
		<slash:comments>170</slash:comments>
		</item>
		<item>
		<title>[Qt] Choose the language</title>
		<link>http://bramas.fr/blog/lang/en/2010/05/07/qt-choix-du-langageqt-choose-the-language</link>
		<comments>http://bramas.fr/blog/lang/en/2010/05/07/qt-choix-du-langageqt-choose-the-language#comments</comments>
		<pubDate>Fri, 07 May 2010 12:38:44 +0000</pubDate>
		<dc:creator>Quentin</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://bramas.fr/?p=115</guid>
		<description><![CDATA[It&#8217;s a good thing to ask for the language at the first launch of the software because it allows the user to choose even if his language isn&#8217;t available (Qt &#8230;<a class="continue_reading_link" href="http://bramas.fr/blog/lang/en/2010/05/07/qt-choix-du-langageqt-choose-the-language">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span lang="en">It&#8217;s a good thing to ask for the language at the first launch of the software because it allows the user to choose even if his language isn&#8217;t available (Qt example doesn&#8217;t do that). </span></p>

<pre class="brush: cpp;">
#include &#60;QTranslator&#62;
#include &#60;QSettings&#62;
#include &#60;QInputDialog&#62;

void setLang(QApplication&#38; app, const QString&#38; idl){
        qWarning(QString(&#34;Lang is %1 (lang_%1)&#34;).arg(idl).toLatin1());

        QTranslator* translator = new QTranslator();
        translator-&#62;load(&#34;SepMin_&#34; + idl,&#34;:/Translations/release&#34;);
        app.installTranslator(translator);
}

void manageLang(QApplication&#38; app){
        QSettings settings(&#34;Bramas.fr&#34;, &#34;AllSepMin&#34;);
        int lang = settings.value(&#34;lang&#34;, -1).toInt();
        if( lang == -1){
                QStringList languages;
                languages &#60;&#60; &#34;English&#34; &#60;&#60; &#34;Francais&#34;;
                lang = languages.indexOf(QInputDialog::getItem(0, &#34;Preference&#34;, &#34;Choose your language ?&#34;, languages, 0, false));
                if(lang == -1){
                        lang = 0;
                }
                settings.setValue(&#34;lang&#34;, lang);
        }

        switch(lang){
                case 0:
                        setLang(app,&#34;en&#34;);
                        break;
                case 1:
                        setLang(app,&#34;fr&#34;);
                        break;
        }
}
int main(int argc, char *argv[])
{

    QApplication a(argc, argv);

    manageLang(a);

    MainWindow w;
    w.show();
    return a.exec();
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bramas.fr/blog/lang/en/2010/05/07/qt-choix-du-langageqt-choose-the-language/feed</wfw:commentRss>
		<slash:comments>176</slash:comments>
		</item>
		<item>
		<title>PicMiz</title>
		<link>http://bramas.fr/blog/lang/en/2010/04/23/picmiz</link>
		<comments>http://bramas.fr/blog/lang/en/2010/04/23/picmiz#comments</comments>
		<pubDate>Fri, 23 Apr 2010 14:11:14 +0000</pubDate>
		<dc:creator>Quentin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://bramas.fr/?p=112</guid>
		<description><![CDATA[Picmiz is a Free Resizer pictures software With Picmiz, you can resize severals pictures in the same time. It’s very light and fast! Picmiz can also put a tag on &#8230;<a class="continue_reading_link" href="http://bramas.fr/blog/lang/en/2010/04/23/picmiz">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Picmiz</strong> is a Free Resizer pictures software<br />
With Picmiz, you can resize severals pictures in the same time. It’s  very light and fast!<br />
Picmiz can also put a tag on the image.</p>
<p>PicMiz is opensource under LGPL licence!!</p>
<p><a href="http://berenger.eu/blog/picmiz/">download and more information</a></p>
<h2>Informations :</h2>
<p><strong>OS :</strong> PC/MAC<br />
<strong>Licence :</strong> Free (opensource)<br />
<strong>Developed in : </strong>C++/Qt<br />
<strong>Author : </strong>Berenger</p>
<p><strong>Languages :</strong> English/French</p>
<p>The softwares on this site are provided “as-is,” without any express  or implied warranty.</p>
<p><strong>Current Version :</strong> 1.0</p>
]]></content:encoded>
			<wfw:commentRss>http://bramas.fr/blog/lang/en/2010/04/23/picmiz/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Users having access to multiple folders in FileZilla Server</title>
		<link>http://bramas.fr/blog/lang/en/2010/03/16/utilisateur-accedant-a-de-multiple-dossier-dans-filezilla-serveurusers-having-access-to-multiple-folders-in-filezilla-server</link>
		<comments>http://bramas.fr/blog/lang/en/2010/03/16/utilisateur-accedant-a-de-multiple-dossier-dans-filezilla-serveurusers-having-access-to-multiple-folders-in-filezilla-server#comments</comments>
		<pubDate>Tue, 16 Mar 2010 17:35:34 +0000</pubDate>
		<dc:creator>Quentin</dc:creator>
				<category><![CDATA[Serveur]]></category>

		<guid isPermaLink="false">http://bramas.fr/?p=79</guid>
		<description><![CDATA[There is a little stuff if you want to add a user having access to multiple folders in FileZilla Serve. Off course you don&#8217;t want to add for each folder &#8230;<a class="continue_reading_link" href="http://bramas.fr/blog/lang/en/2010/03/16/utilisateur-accedant-a-de-multiple-dossier-dans-filezilla-serveurusers-having-access-to-multiple-folders-in-filezilla-server">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span lang="en">There is a little stuff if you want to add a user having access to multiple folders in FileZilla Serve.</span></p>
<p><span lang="en"><span id="more-79"></span><br />
</span></p>
<p><span lang="en">Off course you don&#8217;t want to add for each folder a new user, so let&#8217;s do this.</span></p>
<p><span lang="en">You have to create a  new alias, click right on the folder which is not the home directory, and select &#8220;Edit aliases..&#8221;, and fill in /Folder  . Now this folder is accessible by the home directory as a folder named Folder, great!!</span></p>
<p style="text-align: center;"><a href="http://bramas.fr/wp-content/uploads/2010/03/FZS_aliases.png"><img class="size-medium wp-image-80 aligncenter" title="FZS_aliases" src="http://bramas.fr/wp-content/uploads/2010/03/FZS_aliases.png" alt="" width="488" height="263" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://bramas.fr/blog/lang/en/2010/03/16/utilisateur-accedant-a-de-multiple-dossier-dans-filezilla-serveurusers-having-access-to-multiple-folders-in-filezilla-server/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

