[php] Barre de progression

Vous trouverez ici des morceaux de codes qui peuvent être utiles à votre site.
Verrouillé
Avatar du membre
Dakin Quelia
Webmaster
Webmaster
Messages : 565
Enregistré le : ven. 27 nov. 2009 05:47
Localisation : Belgique
Contact :

[php] Barre de progression

Message par Dakin Quelia »

» Barre de progression

Ce petit code vous permet d'intégrer une barre de progression sur vos pages web, forum ou blogues.

Code : Tout sélectionner

<?php
/**************************************************************************
* @name         - Simple progress bar
* @version      - 1.0.0
* @author       - Efantasy
* @description  - Ceci permet d'intégrer une petite barre de progression
**************************************************************************/
header ("Content-type: image/png");

$percent = 0;
$text = '';

if (isset($_GET['p']))
{
    $percent = $_GET['p'];
    $perx = $percent + 3;
}
else
{
    $percent = 0;
}

$percent = str_replace(' ', '', $percent);
$percent = round($percent);

if ($percent >= 100)
{
    $percent = 100;
    $perx = 179;
}
elseif ($percent < 1)
{
    $percent = 0;
    $perx = 190;
}
elseif ($percent < 10)
{
    $perx = 190;
}
 else
{
        $perx = 185;
}

if (isset($_GET['t']))
{
    $text = $_GET['t'];
}

if (strlen($text) > 34)
{
    $text = substr($text, 0, 34);
}

// Création de l'image
$r = 255-(.83*$percent);
$g = 63+(1.92*$percent);
$b = 66-(.03*$percent);
$img = imagecreatetruecolor(202, 10);
$bg  = imagecolorallocate($img, 100, 100, 100);
$fg = imagecolorallocate($img, 255, 255, 255);
$pg = imagecolorallocate($img, $r, $g, $b);

imagefilledrectangle($img, 0, 0, 202, 10, $bg);
imagefilledrectangle($img, 1, 1, 200, 8, $fg);
if ($percent != 0)
{
    imagefilledrectangle($img, 1, 1, $percent*2, 8, $pg);
}
imagestring($img, 1, 2, 1, $text, $bg);
imagestring($img, 1, $perx, 1, $percent.'%', $bg);
imagepng($img);
imagedestroy($img);

?>

Verrouillé

Qui est en ligne

Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 15 invités