[SPIP] ~maj v2.1.25-->2.1.26
[velocampus/web/www.git] / www / plugins / auto / couteau_suisse / couteau_suisse / outils / spam_options.php
1 <?php
2
3 // traitement anti-spam uniquement si $_POST est rempli et si l'espace n'est pas prive
4 if ( count($_POST)
5 // espace prive en clair dans l'url
6 && (strpos($_SERVER['PHP_SELF'],'/ecrire') === false)
7 // cas des actions
8 && !isset($_POST['action'])
9 ) {
10
11 // champs du formulaire a visiter
12 // un message en forum : texte, titre, auteur
13 // un message a un auteur : texte_message_auteur_XX, sujet_message_auteur_XX, email_message_auteur_XX
14 // inscription : nom_inscription, mail_inscription
15 // login : session_*
16 $spam_POST_reg = ',^(?:texte|titre|sujet|auteur|nom|e?mail|session),i';
17 // on compile $spam_POST en fonction des variables $_POST trouvees
18 $spam_POST_compile = array();
19 foreach (array_keys($_POST) as $key)
20 if (preg_match($spam_POST_reg, $key) && strpos($key, 'password')===false)
21 $spam_POST_compile[] = $key;
22
23 include_spip('cout_lancement');
24 $spam_mots = cs_lire_data_outil('spam');
25 // test IP compatible avec l'outil 'no_IP'
26 $test = $spam_mots[3]?preg_match($spam_mots[3], $ip_):false;
27 foreach ($spam_POST_compile as $var) if(!$test)
28 if(cs_test_spam($spam_mots, $_POST[$var], $test)) $_GET['var'] = $var;
29 if($test) $_GET['action'] = "cs_spam";
30 // nettoyage
31 unset($test, $spam_mots, $spam_POST_reg, $spam_POST_compile);
32
33 function action_cs_spam(){
34 include_spip('inc/minipres');
35 echo minipres(
36 _T('couteau:lutte_spam'),
37 '<pre>'.$_POST[$_GET['var']].'</pre><div>'._T('couteau:explique_spam').'</div>'
38 );
39 exit;
40 }
41 }
42 unset($ip_);
43
44 function cs_test_spam(&$spam, &$texte, &$test) {
45 foreach($spam[0] as $m) $test |= strpos($texte, $m)!==false;
46 if(!$test && $spam[1]) $test = preg_match($spam[1], $texte);
47 if(!$test && $spam[2]) {
48 include_spip('inc/charsets');
49 $test = preg_match($spam[2], charset2unicode($texte));
50 }
51 return $test;
52 }
53
54 ?>