Barre d’avancement


Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /datas/vol4/yulpa163541/var/www/mcstf.me/htdocs/blog/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Voici un script php très utile pour votre site !

Ajoutez une barre d’avancement. Vous pouvez régler la valeur et la taille que vous voulez pour chaque image.

Ce script nécessite l’extension gd de php.

  1. span class= »co1″>// On crée l’image
  2.         $image = imagecreate($dimensions[0], $dimensions[1]);
  3.  
  4.         // On crée les couleurs de l’image
  5. // Calcule les coordonnées des rectangles
  6.         $x1 = $y1 = 0;        // Les bords extérieurs
  7.         $x2 = $y2 = 1;        // L’origine du fond
  8.         $x3 = $y3 = 2;        // L’origine des bords de la barre
  9.         $x4 = $y4 = 3;        // L’origine de la barre
  10.  
  11.         // Les dimensions de la barre
  12.         $w1 = ($dimensions[0]$x41) * ($value/100);
  13.         $h1 = ($dimensions[1]$y41);
  14.  
  15.         // On trace les rectangles
  16. // On enregistre l’image dans un fichier
  17. ‘value’‘width’‘height’"Content-type: image/png"‘width’‘height’‘value’

Il faut ensuite faire comme si ce fichier était une image png:

<img src="votre-fichier.php?value=33&width=200&height=15" alt=""/>

Il doit y avoir ces paramètres:

  • width: largeur de l’image
  • height: hauteur de l’image
  • value: valeur de la barre

Ce script est vraiment basic. Il faudrait surement le modifier pour plus de sécurité (vérifier que les paramètres soient bien des chiffres par exemple).

<?php
$gris = array(192, 192, 192);
$vert = array(0, 192, 0);
$noir = array(0, 0, 0);function create_image($dimensions, $couleur_fond, $couleur_barre, $couleur_bords, $value)
{
if($value < 1)
$value = 1;
if($value > 100)
$value = 100;

// On crée l’image
$image = imagecreate($dimensions[0], $dimensions[1]);

// On crée les couleurs de l’image
$bord = imagecolorallocate($image, $couleur_bords[0], $couleur_bords[1], $couleur_bords[2]);
$barre = imagecolorallocate($image, $couleur_barre[0], $couleur_barre[1], $couleur_barre[2]);
$fond = imagecolorallocate($image, $couleur_fond[0], $couleur_fond[1], $couleur_fond[2]);

// Calcule les coordonnées des rectangles
$x1 = $y1 = 0;        // Les bords extérieurs
$x2 = $y2 = 1;        // L’origine du fond
$x3 = $y3 = 2;        // L’origine des bords de la barre
$x4 = $y4 = 3;        // L’origine de la barre

// Les dimensions de la barre
$w1 = ($dimensions[0] – $x4 – 1) * ($value/100);
$h1 = ($dimensions[1] – $y4 – 1);

// On trace les rectangles
ImageFilledRectangle($image, $x1, $y1, $dimensions[0], $dimensions[1], $bord);
ImageFilledRectangle($image, $x2, $y2, $dimensions[0] – $x2 – 1, $dimensions[1] – $y2 – 1, $fond);
ImageFilledRectangle($image, $x3, $y3, $w1 + 1, $h1 + 1, $bord);
ImageFilledRectangle($image, $x4, $y4, $w1, $h1, $barre);

// On enregistre l’image dans un fichier
imagepng($image);
}

if(isset($_GET[‘value’]) && isset($_GET[‘width’]) && isset($_GET[‘height’]))
{
header(« Content-type: image/png »);
create_image(array($_GET[‘width’],$_GET[‘height’]), $gris, $vert, $noir, $_GET[‘value’]);
}
?>