source: extensions/Mail_supervisor/include/fonctions.php @ 4327

Last change on this file since 4327 was 4327, checked in by cljosse, 14 years ago

[mail_supervisor] Improvement of the management of the spammers.

File size: 22.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die('Hacking attempt!');
27}
28
29if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
30
31
32 if (!isset($_COOKIE[session_name()]))
33{
34
35
36
37}
38include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
39include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');
40include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
41global $lang ;
42
43
44include_once (MAIL_SUPERV_PATH.'include/function_test_send.php'); 
45
46
47    load_language('plugin.lang', MAIL_SUPERV_PATH);
48
49
50global  $superv_champs , $superv_type ,$superv_bl_champs , $superv_bl_type ; 
51         
52//==========================================================
53function sauve_options()
54{
55global $mails_options ;
56 if ( isset($mails_options) )
57        {
58          if ( count($mails_options) > 6 ) 
59           {
60                $valeurs = implode( ',',$mails_options);
61                $query = '
62                UPDATE '.CONFIG_TABLE.'
63                SET value="'. $valeurs . '"
64                WHERE param = "mail_superv"
65                LIMIT 1';
66                        pwg_query($query);
67          }
68        }
69}
70//=================================================================================
71function sauve_données()
72{
73
74global $mails_données,$superv_champs,$superv_type,$erreur_message ;
75//=====================================================================
76        $clefs = $superv_champs ;
77        $valeurs = array();
78
79foreach ( $clefs as $champ)
80   {
81     $champ = trim($champ);
82     
83         if ( isset($mails_données[  $champ ]) ) {
84           $sep= (is_string($mails_données[ $champ ])) ? '"' : '' ;
85       array_push($valeurs , "`".$champ."`" . ' = ' . $sep . $mails_données[  $champ ] . $sep)  ;
86         }else{
87         
88            array_push($valeurs , "`".$champ."`" . ' = ' .  "0"  )  ;
89         }
90    }
91$valeurs = implode(", ",$valeurs) ;
92//=====================================================================
93$query = '
94        UPDATE '.MAIL_SUPERV_TABLE.'
95        SET '. $valeurs .'
96                WHERE `id` = 1 LIMIT 1 ';
97                ;
98        ob_start();
99                $ret=  pwg_query($query)    ;
100                $m= ob_get_contents();
101        ob_end_clean() ;
102        $erreur_message .= $m ;
103
104}
105         
106//=================================================================================
107function affiche_message()
108{
109 global $template,$infos_message,$erreur_message, $user ;;
110
111global $mails_options,$conf,$lang ;
112
113$mails_options = explode("," , $conf['mail_superv']);
114
115 if ( count($_POST)==5 || count($_POST)==0 ) {
116        if (kill_list())
117                 {
118                  $erreur_message .= "<BR />".l10n('is_a_spam') ;
119                 if ($mails_options[4] == 'on' ){
120               
121//[status] => guest
122//[status] => normal
123//[status] => webmaster
124                 
125                        if ($user['status'] != 'webmaster'  )
126                                if (!isset($_GET['admin'])) {
127                                                 die('Blacklist : <br />' .$erreur_message. '<br /> Hacking attempt!');
128                                }elseif   ($_GET['admin'] != 'piwigo')
129                                        {
130                                                 die('blacklist Hacking attempt!');
131                                        }
132           }
133        }
134 }       
135
136 //==============================================================
137  if (isset($erreur_message))
138                {       
139 
140                if ($erreur_message <> "")
141                        {
142                            $erreur_message=str_replace("\n",'<br />',$erreur_message) ;
143                                $template->assign('errors',$erreur_message);
144                                $erreur_message="";
145                        }
146                }
147               
148       
149  if (isset($infos_message))
150                {       
151               
152                if ($infos_message <> "")
153                        {
154                                $infos_message=str_replace("\n",'<br />',$infos_message) ;
155                                $template->assign('infos',$infos_message);
156                                $infos_message="";
157                        }
158                }
159                //=============================================================
160       
161       
162return;         
163               
164}
165
166function Get_geo()
167{
168global $pays,$region,$ville ;
169 if (!isset($_POST['submit'])) {
170   if (!isset($_POST['ville'])) 
171     {
172            $result="";
173            $src =  "http://j.maxmind.com/app/geoip.js" ;
174        if ( !fetchRemote($src , $result))
175                {
176         
177                ?>
178<script language="JavaScript" type="text/javascript">
179            var pays     =  "??";
180                        var ville     =  "??";
181                        var region    =  "??";
182                        var latitude  =  "??";
183                        var longitude =  "??";
184</script>
185<?php
186                }else{
187?>
188<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js" type="text/javascript" >
189</script>         
190<script language="JavaScript" type="text/javascript">
191            var pays     =  geoip_country_name();
192                        var ville     =  geoip_city();
193                        var region    =  geoip_region_name() ;
194                        var latitude  =  geoip_latitude() ;
195                        var longitude =  geoip_longitude() ;
196                       
197</script>
198<?php
199                }
200?>             
201<form action="" method="post" name="form_connexion" id="form_connexion" style="visibility:hidden">
202<script language="JavaScript" type="text/javascript">                  
203                document.write ("<input name=\"pays\"  type=\"text\" value =  "+ pays + "  id = \"pays\"  > ");
204                document.write ("<input name=\"ville\"  type=\"text\" value = "+ ville + "  id = \"ville\"   >  ");
205                document.write ("<input name=\"region\"  type=\"text\" value =  "+ region + "   id = \"region\"   > ");
206                document.write ("<input name=\"latitude\"  type=\"text\" value =  "+ latitude + " id = \"latitude\"   > ");
207                document.write ("<input name=\"longitude\"  type=\"text\" value = "+ longitude + " id = \"longitude\"  >  ");
208</script>       
209</form >
210<script language="JavaScript" type="text/javascript"> 
211  document.getElementById("form_connexion").submit();
212</script>
213?>     
214<?php   
215     }
216 }
217                $pays = isset($_POST['pays']) ? $_POST['pays'] : $pays ;
218                $ville = (isset($_POST['ville']))   ? $_POST['ville']: $ville ; 
219                $region =  isset($_POST['region']) ? $_POST['region'] : $region;       
220               
221}
222
223//=================================================================================
224function Get_Datas()
225{
226global $superv_champs ;
227$champs = implode(",",$superv_champs );
228    $query = "SELECT ".$champs."
229    FROM ".MAIL_SUPERV_TABLE."
230        ;";
231                         $result = @pwg_query($query);
232 
233        if (!$result) {
234                                        vérif_base();
235                                        $result = @pwg_query($query);
236                                        }
237
238                                       
239    $data = mysql_fetch_array($result,MYSQL_ASSOC);
240        //====================================================================================
241        $next_day = Str_To_Time( $data['nb_mails_periode'], $data['date_mail'] );;
242        $data['rest_mail']=    $next_day - time() ;
243
244        $next_day =  + Str_To_Time( $data['nb_spams_periode'],$data['date_spam']);
245        $data['rest_spam']=  $next_day - time() ;
246
247
248        $next_day = Str_To_Time($data['quarantaine_periode'] ,$data['date_quarantaine']);       
249       
250        if ($data['quarantaine'] == 'true' ) {
251                        $data['reste'] =   ( $next_day )-time() ;
252        }else{
253                        $data['reste'] = 0;
254        }
255       
256         return $data;
257}
258//===============================================
259
260function corrige_header($Carbonne,$headers,$args)
261        {
262        global $mails_options,$conf_mail,$mailto,$infos_message;
263
264 if (!empty($args[$Carbonne]))
265         {
266 
267                if ( count($args[$Carbonne]) > 0 ) 
268                {
269                 if ($mails_options[1] == 'on') {
270                        $list_mail  = str_replace(","," ,",get_strict_email_list(implode(',', $args[$Carbonne])))." \n" ;
271                        $headers = preg_replace('/.*'.$Carbonne.'(.*).\n/i', $Carbonne.': '.$list_mail, $headers);
272                 }
273                }
274        } else {
275        // Raz Bcc, Cc dans headers
276                        $headers = preg_replace('/.*'.$Carbonne.'(.*).\n/i', "" , $headers);
277        }
278               
279               
280return $headers;
281
282               
283        }
284       
285function int_to_heure($int)
286{
287
288        $delta=(7*24*60*60) ;
289        $week = (int) ($int/$delta); 
290        $int= $int-($week*$delta) ; 
291
292        $delta=(24*60*60) ;
293        $day= (int) ($int/$delta); 
294        $int=$int-($day*$delta);
295
296        $delta=(60*60) ;
297        $heures=(int) ($int/$delta);
298        $int=$int-($heures*$delta);
299
300        $delta=(60) ;
301        $minutes=(int) ($int/$delta);
302        $int= $int - ($minutes*$delta);
303
304        $secondes=(int) ($int);
305        $day      = substr ('00'.    $day,-2,2);   
306        $heures   = substr ('00'. $heures,-2,2);   
307        $minutes  = substr ('00'.$minutes,-2,2);
308        $secondes = substr ('00'.$secondes,-2,2);
309
310   
311if ($week > 0 )
312{
313        return $week. " " .l10n('Week'). " " .  $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " .    $minutes. " " .l10n('minute'). "s ".  $secondes." " .l10n('seconde')."s";
314}
315return $day . " " .l10n('Day'). "s ". $heures . " ". l10n('Hour'). "s " . $minutes. " " .l10n('Minute'). "s ".  $secondes." " .l10n('Seconde')."s";
316
317}       
318
319function memo_var($variables)
320{
321                ob_start();
322                echo '<pre>';
323                print_r($variables);
324                echo '</pre>';
325                $m= ob_get_contents();
326
327        ob_end_clean();
328                return $m;
329               
330}
331   
332
333       
334function vérif_base()
335{
336
337global $lang,$superv_champs,$superv_type,$superv_bl_champs,$superv_bl_type;
338    load_language('plugin.lang', MAIL_SUPERV_PATH);
339//==============================================================================               
340    create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
341        ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type)  ; 
342//==============================================================================               
343        create_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type) ;
344        ajust_table(MAIL_SUPERV_TABLE,$superv_champs,$superv_type)  ;
345//==============================================================================               
346    $valeurs= array (   1,
347                                                0,
348                           time(),
349                         2000,
350         '"1 '.l10n('Week').'"' ,
351                            0,
352                  time(),
353                           10,
354          '"2 '.l10n('Day').'"',
355                       '"false"',
356                time(),
357          '"2 '.l10n('Day').'"',
358       
359                      '"Init"',
360   '"'.l10n('supervisor').'"',
361        '"'.l10n('hello').'"',
362         )
363        ;
364//==================================================================================
365        ajout_ligne(MAIL_SUPERV_TABLE,$superv_champs, $valeurs,false ) ;
366       
367
368}
369
370//=========================================
371function Get_colonnes_de($table)
372{
373    $query = 'DESC '.$table.';';
374    $result = mysql_query($query);
375    $columns_of= array();
376    while ($row = mysql_fetch_row($result))
377    {
378      array_push($columns_of, $row[0]);
379    }
380 
381  return $columns_of;
382}
383
384function get_liste($group_id)
385{
386global $conf ;
387
388  $query = '
389SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
390                u.'.$conf['user_fields']['username'].' AS username,
391                u.'.$conf['user_fields']['email'].' AS email,
392                ui.status,
393                ui.adviser,
394                ui.enabled_high,
395                ui.level
396  FROM '.USERS_TABLE.' AS u
397    INNER JOIN '.USER_INFOS_TABLE.' AS ui
398      ON u.'.$conf['user_fields']['id'].' = ui.user_id
399    LEFT JOIN '.USER_GROUP_TABLE.' AS ug
400      ON u.'.$conf['user_fields']['id'].' = ug.user_id
401  WHERE ug.group_id='.$group_id.' ';
402
403
404 
405 $groups=array();
406  $datas = pwg_query($query);
407 
408 
409  if (!empty($datas))
410  {
411    while ($group = mysql_fetch_array($datas,MYSQL_ASSOC))
412    {
413
414       
415      if (!empty($group['email']))
416      {
417        array_push($groups, format_email($group['username'], $group['email'] ));
418      }
419    }
420  } 
421  return $groups ;
422 
423}
424//=================================================================================
425
426function create_table($nom_table,$champs,$types)  //MAIL_SUPERV_TABLE
427{
428        $i=0;
429        $valeurs=array();
430foreach ( $champs as $champ)
431   {
432        $champ = trim($champ);
433                array_push($valeurs , " `".$champ."`" . '  ' . $types[ $i] )  ;
434                $i +=1;
435    }
436
437
438       
439        if ( count($valeurs) == 0) return ;
440
441    $valeurs=implode(", ",$valeurs) ;
442        //===============================================================================
443                $query = "CREATE TABLE IF NOT EXISTS  `" . $nom_table . "` (". $valeurs . " , PRIMARY KEY  (`id` ) ) ;"; 
444                         if ( pwg_query($query) ) return ; 
445                                die("ERREUR CREATION ".$query);         
446     
447         
448}
449function ajust_table($nom_table,$champs,$types)  //MAIL_SUPERV_TABLE
450{
451global $infos_message ;
452$colonnes = Get_colonnes_de($nom_table);
453        $data =         $types ;
454        $i=0;
455        $valeurs=array();
456foreach ( $champs as $champ)
457   {
458     $champ = trim($champ);
459          if (!in_array( $champ,$colonnes)) {
460         array_push($valeurs , " ADD `".$champ."`" . '  ' . $data[  $i] )  ;
461         }
462         $i +=1;
463         
464    }
465//=============================================================================
466        if ( count($valeurs) == 0) return ;
467       
468  $infos_message .=  "AJUSTE TABLE : ". $nom_table . "<br />" . "NB (col) : ". count($colonnes) . memo_var($valeurs) . "<br />" ;
469       
470     $valeurs=implode(", ",$valeurs) ;
471        //===============================================================================
472                $query = "ALTER TABLE `" . $nom_table . "` ". $valeurs ;
473                        if (   pwg_query($query)) return ;           
474                die($query);
475}
476//==============================================================================       
477function ajout_ligne($nom_table,$champs,$valeurs,$force)
478{
479  if (!$force) {
480     $query = "
481                SELECT `id` , COUNT(`id`) as total
482                FROM `".$nom_table."`
483                ;";     
484          list($count) = mysql_fetch_row(pwg_query($query));
485
486               
487}else{
488
489        $count = 0 ;
490}
491 
492  if ($count == 0)
493  {
494      $n_champs=implode(",",$champs);
495      $n_valeurs=implode(",",$valeurs);
496           $query = "
497        INSERT INTO `".$nom_table."` (". $n_champs.")
498        VALUES ( ".     $n_valeurs .")";
499               
500                if (pwg_query($query)) return ;
501                die($query);
502               
503  }
504}
505//=====================================================================
506
507function Str_To_Time( $ajout,$init_date)
508{
509//========================================================
510  global $erreur_message;
511$a_ajouter=$ajout ;
512
513        $period_search=array("W","D","H","M","S");
514                       array_push($period_search,l10n('Week').'s',l10n('Day').'s',l10n('Hour').'s',l10n('Minute').'s',l10n('Seconde').'s');
515                               array_push($period_search,l10n('Week'),l10n('Day'),l10n('Hour'),l10n('Minute'),l10n('Seconde'));
516
517
518       
519        $period_match = array(' week ',' day ',' hour ',' minute ',' seconde ');       
520                        array_push($period_match,' week ',' day ',' hour ',' minute ',' seconde ');
521                        array_push($period_match,' week ',' day ',' hour ',' minute ',' seconde ');
522       
523
524       
525$a_ajouter = "+ " .  str_replace($period_search, $period_match, $a_ajouter) ;
526$a_ajouter=sup_double_espace($a_ajouter);
527
528$v1 = array('- ','+ ','week','day','hour','minute','seconde',' -',' +',' ');
529$v2 = array('-','+', (7*24*60*60) ,  (24*60*60),  (60*60),  60,1,'|-','|+',"*" );
530$new_valeur =  str_replace($v1,$v2,$a_ajouter) ;
531$new_valeur =  str_replace('++','+',$new_valeur ) ;
532
533$new_valeur = explode( "|",$new_valeur );
534$p = $init_date ;
535
536        //$new_valeur = $a_ajouter + $init_date ;
537        foreach($new_valeur as $nv)
538        {
539        $return = matheval($nv) ;
540                 if (strpos("error",$return)===false) {
541                    $p += $return ;
542                 }else {
543                 $erreur_message .= $return . " nv : " .  $nv ;
544                 }
545                       
546         
547        }
548return  $p ;
549 
550}
551//=====================================================================================
552function matheval($equation) 
553  { 
554
555  $return="error";
556
557 
558    $equation = preg_replace("/[^0-9+\-.*\/()%]/","",$equation); 
559    $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation); 
560    $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation); 
561    $equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation); 
562       
563    if ( $equation == "" ) 
564    { 
565      $return = 0; 
566    }     else  { 
567       @eval("\$return=" . $equation . ";" ); 
568    }
569 return $return; 
570   
571  } 
572
573//======================================================================================
574function sup_double_espace($chaine){
575global $erreur_message;
576        $str_temp = $chaine." ";
577        $sep=" ";
578        $chaine = trim($chaine);
579        $existe = (strpos($sep.$sep,$chaine )===false) ;
580         while  ($existe ){
581         $str_temp = str_replace($sep.$sep, $sep, $chaine ); 
582                if($str_temp == $chaine ) return $chaine ;
583//                      $erreur_message .= memo_var($str_temp) ;
584                $chaine  = $str_temp;
585                        $existe =  (strpos($sep.$sep,$chaine )===false) ;
586                }
587        return $chaine;
588}
589
590
591
592function kill_list()
593{
594 //==================== TEST black_liste ============================================   
595 global $pays,$region,$ville,$ip ;
596 global $erreur_message,$infos_message,$conf;   
597 global $conf, $user, $page;
598 global $mails_options ;
599 global $superv_bl_champs,$superv_bl_type ; 
600 global $nb ;
601 
602if (count($mails_options) < 7 ) return false ;
603
604  $ip = $_SERVER['REMOTE_ADDR'] ;
605  if ( !isset($_POST['pays'])) {       
606      if ( !isset($_POST['ip_black_test'])) {
607                            Get_Geo();         
608                        }
609                 return ;       
610                }  else {
611                       $pays = (isset($_POST['pays'])) ? $_POST['pays'] : "" ;
612                       $ville = (isset($_POST['ville']))   ? $_POST['ville'] : "" ; 
613                       $region = ( isset($_POST['region'])) ? $_POST['region'] : "" ;   
614        }
615     $champs=implode(',',$superv_bl_champs);
616     $query = "
617                SELECT ".$champs.",COUNT(`ip`) as total
618                FROM `".MAIL_BLACK_LISTE_TABLE."`
619                    WHERE '".$ip."' LIKE `ip`
620                ;";     
621                 $result = @pwg_query($query);
622        if (!$result) {
623                                        vérif_base();
624                                        $result = @pwg_query($query);
625                                }
626        $datas = mysql_fetch_array($result,MYSQL_ASSOC);
627        $nb = $datas['total']; 
628//=======================================================================       
629
630if ($mails_options[5] == 'on')
631{
632 // $ip="94.102.63.13"; ' Spammeurs
633 // $ip="94.102.63.15";
634 // $mail=matusowraber93813@gmail.com ;
635 // $username=fretgpsolodens ;
636  if (test_spam($ip,$user['username'] ,$user['email']))
637  {
638  if ($nb==0) {
639        $valeurs=array( 'NULL',
640                            "'".$ip."'",
641                                        "'".$pays."'",
642                                        "'".$region."'",       
643                                        "'".$ville."'",
644                                        "'".$user['email']."'",
645                                        "'".$user['username']."'",     
646                                        $nb+1
647        );
648          ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,$nb==0) ;     
649        }else{ 
650       
651        $nb +=1;
652       
653                 $query ="
654                        UPDATE " . MAIL_BLACK_LISTE_TABLE . "
655                        SET ";
656                    if (isset($_POST['pays'])) 
657                 $query .= "   
658                        `pays` = '". $pays ."',
659                        `region` = '" . $region ."',
660                        `ville` = '" . $ville . "',
661                       
662                        ";
663                       
664                 $query .= "
665                    `adresse` = '".$user['email']."',           
666                        `fai` = '".$user['username']."',               
667                        `nb` = " . $nb . "
668                    WHERE '".$ip."' like `ip`
669                ";
670               
671                                pwg_query($query );     
672        }
673          $erreur_message .=  $mails_options[6] ." ".$user['username']." ".$user['email'] . ' -----> ' . l10n('black_list') ;
674        // die($nb." ".$ip." ".$user['username']." ".$user['email']); 
675        return true ;   
676
677    }
678 
679}
680 //==============================================================================
681
682 if ( $mails_options[6] == $ip ) return ($nb > 0) ;     
683 
684   $mails_options[6] =   $ip ; 
685   sauve_options();
686 
687        if (  $nb > 0 )
688        {
689               $query = "
690                SELECT ".$champs.",COUNT(`id`) as total
691                FROM `".MAIL_BLACK_LISTE_TABLE."`
692                    WHERE '".$ip."' = `ip`
693                ;";     
694                 $result = @pwg_query($query);
695 
696        if (!$result) {
697                                        vérif_base();
698                                        $result = @pwg_query($query);
699                                        }
700            $datas = mysql_fetch_array($result,MYSQL_ASSOC);
701                 $nb = $datas['total']; 
702                 
703            $row  = mysql_fetch_row(pwg_query($query));
704            $nb =  ($row[7]);
705      $erreur_message .= $ip . ' | ' . $pays . ' | ' . $region . ' | ' . $ville . ' ' . $nb . ' ==> '; 
706 
707         if ($nb == 0)
708                 {
709                        $valeurs=array( 'NULL',
710                            "'".$ip."'",
711                                        "'".$pays."'",
712                                        "'".$region."'",       
713                                        "'".$ville."'",
714                                        "'".$user['email']."'",         
715                               "'".$user['username']."'",               
716                                        1
717              );
718                  ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,true) ;       
719                 
720                 } else {
721                  $nb += 1;
722         $query ="
723                        UPDATE " . MAIL_BLACK_LISTE_TABLE . "
724                        SET ";
725                if (isset($_POST['pays']))     
726                 $query .= "   
727                        `pays` = '". $pays ."',
728                        `region` = '" . $region ."',
729                        `ville` = '" . $ville . "',
730                        ";
731                 $query .= "   
732                    `adresse` = '".$user['email']."',
733                        `fai` = '".$user['username']."',                       
734                        `nb` = " . $nb . "
735                    WHERE '".$ip."' = `ip`
736                ";
737               
738                                pwg_query($query );     
739                                }
740        //================================================================================     
741               
742        }
743 
744
745return ($nb > 0) ;
746}
747//=====================================================================================
748function test_spam($ip =0,$user_name ='', $mail_adresse = "")
749{
750$buffer="";
751// fretgpsolodens
752$src =  "http://www.stopforumspam.com/api?";
753$type=array();
754$result="";
755$user_name=str_replace(" ","%20",$user_name);
756$mail_adresse =str_replace(" ","%20",$mail_adresse);
757if ( strlen($user_name) > 3)      $type[]="username=$user_name" ;
758if ( strlen($mail_adresse) > 3)   $type[]="email=".$mail_adresse ;
759if ( strlen($ip) > 3)   $type[]="ip=".$ip ; 
760 
761         foreach  ( $type as $fil )
762     {   
763           $resultat="";
764           if (  fetchRemote($src.$fil , $resultat))
765                  {
766                  $result .= $resultat.'<br />'  ; 
767                  }  else {
768                 
769                  }
770      }
771
772return !(strpos(  $result ,'yes' ) === false) ;
773 
774}
775//==================================================================
776function lire_fichier_distant($fichier)
777{
778 $buffer="";
779        $handle =  @fopen($fichier,"r"); 
780        if ($handle) {
781                       while (!feof($handle)) { 
782                       $buffer .= fgets($handle, 4096);
783                                  }   
784                                   fclose($handle);
785                                }
786                                 
787        return  $buffer ;
788
789}
790               
791?>
Note: See TracBrowser for help on using the repository browser.