.01
.02
.03
.04
.05
.06
.07
.08
.09
.10
.11
.12
.13
.14
.15
.16
.17
.18
.19
.20
.21
.22
.23
.24
.25
.26
.27
.28
.29
.30
.31
.32
.33
.34
.35
.36
.37
.38
.39
.40
.41
.42
.43
.44
.45
.46
.47
.48
.49
.50
.51
.52
.53
.54
.55
.56
.57
.58
.59
.60
.61
.62
.63
.64
.65
.66
.67
.68
.69
.70
.71
.72
.73
.74
.75
.76
.77
|
|
<?php
/******************************************************************************/
/* */
/* __ ____ */
/* ___ / / ___ / __/__ __ _____________ ___ */
/* / _ \/ _ \/ _ \_\ \/ _ \/ // / __/ __/ -_|_-< */
/* / .__/_//_/ .__/___/\___/\_,_/_/ \__/\__/___/ */
/* /_/ /_/ */
/* */
/* */
/******************************************************************************/
/* */
/* Titre : Trouver le spam dans un texte */
/* */
/* URL : http://www.phpsources.org/scripts465-PHP.htm */
/* Auteur : KOogar */
/* Date édition : 08 Nov 2008 */
/* Website auteur : http://www.phpsources.org */
/* */
/******************************************************************************/
$nombres_de_lettes_max = 4;
// les consonnes
$consonnes = array("b","c","d","f","g","h","j","k","m","n",
"p","q","r","s","t","v","w","x","z");
// les voyelles
$voyelles = array("a","e","i","o","u","y");
// les exceptions en 4 lettres (comme le $nombres_de_lettes_max)
$exceptions = array("http","aaaa","uuuu");
// votre texte
$texte = "hello worrrrrdddd come to seeeee myyyy webtrhdtgrbvx
aaaaaat http://www.helloword.com siiiiite";
// variables
$i=0; $v=0; $c=0; $stock_consonne='';$stock_voyelle='';
while ($i<=strlen($texte)) {
// on sauvegarde le contenu de last_var pour refaire une comparaison
$last_var_sub = $last_var;
// on gere les consonnes
if (in_array($texte[$i],$consonnes))
{$stock_consonne .= $texte[$i]; $i++;$c++;$last_var='consonne';}
// on gere les voyelles
elseif (in_array($texte[$i],$voyelles))
{$stock_voyelle .= $texte[$i]; $i++; $v++; $last_var='voyelles';}
// si c'est un caratere autre on met tout a zero
else{$v=0;$c=0;$i++;$stock_consonne=''; $stock_voyelle='';}
// test sur les egalités
if ($c==$nombres_de_lettes_max) {
if (!in_array($stock_consonne,$exceptions))
echo 'spam consonne -> '.$stock_consonne.'<br />';
$v=0;$c=0;$stock_consonne='';
}
if ($v==$nombres_de_lettes_max) {
if (!in_array($stock_voyelle,$exceptions))
echo 'spam voyelle -> '.$stock_voyelle.'<br />';
$v=0;$c=0;$stock_voyelle='';
}
// si la lettre est differente on reinitialise
if ($last_var_sub != $last_var)
{$v=0;$c=0; $stock_consonne=''; $stock_voyelle='';}
}
/*
Affiche:
spam consonne -> rrrr
spam consonne -> dddd
spam voyelle -> eeee
spam consonne -> trhd
spam consonne -> tgrb
spam voyelle -> iiii
*/
?>
|