853b4d316c977540784da483ae0148c38e29ecc9
[lhc/web/www.git] / www / plugins / nospam / nospam / verifier_formulaire_forum.php
1 <?php
2
3 /**
4 * Plugin No-SPAM
5 * (c) 2008 Cedric Morin Yterium.net
6 * Licence GPL
7 *
8 */
9
10 if (!defined("_ECRIRE_INC_VERSION")) return;
11
12 /**
13 * Verification supplementaire antispam sur le formulaire_forum
14 *
15 * @param array $flux
16 * @return array
17 */
18 function nospam_verifier_formulaire_forum_dist($flux){
19 $form = $flux['args']['form'];
20 if (!isset($flux['data']['texte'])
21 AND $GLOBALS['meta']['forums_texte'] == 'oui'){
22
23 $texte = _request('texte');
24 include_spip("inc/nospam");
25 // regarder si il y a du contenu en dehors des liens !
26 $caracteres = compter_caracteres_utiles($texte);
27 $min_length = (defined('_FORUM_LONGUEUR_MINI') ? _FORUM_LONGUEUR_MINI : 10);
28 if ($caracteres < $min_length){
29 $flux['data']['texte'] = _T('forum_attention_dix_caracteres');
30 }
31
32 // regarder si il y a du contenu cache
33 if (!isset($flux['data']['texte'])){
34 $infos = analyser_spams($texte);
35 if (isset($infos['contenu_cache']) AND $infos['contenu_cache']){
36 $flux['data']['texte'] = _T('nospam:erreur_attributs_html_interdits');
37 }
38 }
39
40 // regarder si il y a des liens deja references par des spammeurs
41 if (!isset($flux['data']['texte'])
42 AND isset($infos['liens'])
43 AND count($infos['liens'])){
44
45
46 if ($h = rechercher_presence_liens_spammes($infos['liens'],_SPAM_URL_MAX_OCCURENCES,'spip_forum',array('texte'))){
47 spip_log("Refus message de forum qui contient un lien vers $h","nospam");
48 $flux['data']['texte'] = _T('nospam:erreur_url_deja_spammee');
49 }
50 }
51
52 // on prend en compte la checkbox de confirmation
53 // si le flag en session est bien leve
54 if (_request('notabuse')){
55 session_start();
56 if ($_SESSION['notabuse_check']){
57 unset($_SESSION['notabuse_check']);
58 $_SESSION['notabuse_checked'] = true;
59 // on leve une globale pour la fin de ce hit, a toute fin utile (puisque plus rien en $_SESSION)
60 $GLOBALS['notabuse_checked'] = true;
61 }
62 }
63 if (!count($flux['data'])){
64 if (nospam_check_ip_status($GLOBALS['ip'])!=='ok'){
65 session_start();
66 if ($_SESSION['notabuse_checked']){
67 // ok on retire de la session le check qui ne sert qu'une fois
68 unset($_SESSION['notabuse_checked']);
69 // et on laisse passer
70 }
71 else {
72 $flux['data']['texte'] = _T('nospam:info_ip_suspecte')."<br />
73 <span class='choix'>
74 <input type='checkbox' name='notabuse' value='1' id='notabuse'/> <label for='notabuse'>"
75 ._T('nospam:label_message_licite')."</label>
76 </span>";
77 $_SESSION['notabuse_check'] = true;
78 spip_log("notabuse_check sur IP ".$GLOBALS['ip'],"nospam");
79 }
80 }
81 }
82
83
84 if (isset($flux['data']['texte']))
85 unset($flux['data']['previsu']);
86 }
87
88 return $flux;
89 }