Aller vu que je suis un gros producteur de fonction a la con je mis met aussi :p:
Code PHP :
<?php
//Détecter l'ip
function get_ip()
{
return (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
}
//fonction de calcule de %tage
function pourcent($nombre,$pourcent)
{
$nbr = ($nombre*$pourcent)/100;
return round($nbr);
}
//Crée une barre de statut
function statut_barre($valeur,$max,$echelle)
{
$size = ($valeur/$max)*$echelle;
return '<div style="height:13px; width:'.$echelle.'px; float:left; background-color:#FF0000;
-moz-border-radius:15px;"><div style="float:left; height:10px; width:' . $size .
'px; background-color:#008000;border:#006400 2px solid; -moz-border-radius:15px;"> </div></div>';
}
//Fontion affichage de message alerte
function alert($mess)
{
echo '<script language=\'javascript\'>alert(\'',str_replace('"','\"',str_replace('\'','\\\'',$mess)),'\');</script>';
}
//Fonction bbcode
function bbcode($t)
{
$t = preg_replace("!\[(url|email)\](.+)\[/(?:url|email)\]!Ui","[$1=$2]$2[/$1]",$t);
$t = preg_replace("!\[url=([^\]]+)\](.+)\[/url\]!Ui","<a href=\"$1\" target=\"_blank\">$2</a>",$t);
$t = preg_replace("!\[email=([^\]]+)\](.+)\[/email\]!Ui","<a href=\"mailto:$1\" target=\"_blank\">$2</a>",$t);
$t = preg_replace("!\[img\](.+)\[/img\]!Ui","<img src=\"$1\" alt=\"\" border=\"0\">",$t);
$t = preg_replace("!\[(/?[biu])\]!mi","<$1>",$t);
$t = preg_replace("!\[color=([^\]]+)\]!mi","<font style=\"color: $1;\">",$t);
$t = preg_replace("!\[size=([^\]]+)\]!mi","<font style=\"font-size: $1px;\">",$t);
$t = preg_replace("!\[/(?:color|size)\]!i","</font>",$t);
//$q1 et $c1 sont à personnaliser...
$q1 = "<table align=center border=0 cellpadding=3 cellspacing=1 width=90%><tbody><tr><td><span style=\"font-size : 11px\"><b>";
$q2 = "</b></span></td></tr><tr><td style=\"font-family: Verdana, sans-serif; font-size: 11px; color: #444444;
background-color: #FAFAFA; border: #D1D7DC; border-style: solid; border-width: 1px\">";
$q3 = "</td></tr></tbody></table>";
$t = preg_replace("!\[quote=([^\]]+)\](.+)\[/quote\]!Umi","$q1 $1 a écrit :$q2 $2 $q3",$t);
$t = preg_replace("!\[quote\](.+)\[/quote\]!Umi","$q1 Citation : $q2 $1 $q3",$t);
$c1 = "<table align=center border=0 cellpadding=3 cellspacing=1 width=90%><tbody>
<tr><td style=\"font-family: TimesNewRoman, sans-serif; font-size: 11px;
color: #444444; background-color: #FAFAFA;
border: #D1D7DC; border-style: solid; border-width: 1px\">";
$t = preg_replace("!\[code\](.+)\[/code\]!Umi","$c1 $1 $q3",$t);
$t = preg_replace("!\[list\](.+)\[/list\]!Umi","<ul> $1 </ul>",$t);
$t = preg_replace("!\[\*\](.+)(?=(\[\*\]|</ul>))!Umi","<li>$1</li>",$t);
return $t;
}
//Fonction de redirection
function redirect($url)
{
echo '<script language=\'javascript\' type=\'text/javascript\'>
<!--
window.location.replace(\'',$url,'\');
-->
</script>';
exit;
}
//Fonction qui supprime tout les saut de ligne (dans tout les OS !)
function new_trim($src)
{
$src = str_replace(array("\r\n", "\n", "\r"), " ", $src);
return $src;
}
//Detecter si un objet est proche d'un autre a partir de leur coordonnée
function isProche($xA,$yA,$xB,$yB,$d)
{
return max(abs($xA-$xB),abs($yA-$yB)) <= $d;
}
//supprime les n° d'un chaine
function no_num($chaine)
{
$num = '1234567890';
$nonum= ' ';
$chaine = strtr(trim($chaine),$num,$nonum);
$chaine = str_replace(' ', '', $chaine);
return $chaine;
}
Y en a des très conne je sais :good:
Phenix