source: extensions/Mail_supervisor/include/save_info.php @ 4190

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

[mail_supervisor] Added option updated automatically blacklist

File size: 3.3 KB
Line 
1<?php
2
3
4//=======================================================================================
5
6
7if (!defined('MAIL_SUPERV_PATH')) define('MAIL_SUPERV_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
8
9//include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
10include_once (MAIL_SUPERV_PATH.'include/constants.php'); 
11include_once (MAIL_SUPERV_PATH.'include/fonctions.php'); 
12
13    $info_ip = (isset($info_ip)) ? $info_ip : '' ;
14    $info_ip = (isset($_POST['info1'])) ? $_POST['info1'] : $info_ip ;
15    $info_ip = (isset($_POST['info'])) ? $_POST['info'] : $info_ip ;
16    $info_ip .= ":";
17 
18   $val=explode(":",$info_ip);
19   $info_ip = trim($val[0]) ;
20   $ip_black = trim($val[1]) ;
21 
22  if (isset($_POST['ip_black']))
23   $ip_black = ($ip_black == "" ) ? $_POST['ip_black'] : $ip_black ;
24global $n ;
25
26Global $pays,$region,$ville ;
27 
28switch ($info_ip)
29 {
30
31  case 'ajout':
32  $n +=1;
33//echo " |$n] ". (( isset($_POST['info']) ) ? " POST  :".$_POST['info'] : "" ).(( isset($_POST['info1']) ) ? " POST   1 :".$_POST['info1'] : "" )."|";   
34 
35 if (!($ip_black == '')) {
36    create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
37        ajust_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type)  ;
38
39   $query = "
40                SELECT COUNT(`id`) as total
41                FROM `".MAIL_BLACK_LISTE_TABLE."`
42                    WHERE ip = '".$ip_black."'
43                ;";     
44
45               
46//==============================================================================               
47list($count) = mysql_fetch_row(pwg_query($query));
48//==============================================================================       
49       
50        $valeurs=array( 'NULL',
51                            "'".$ip_black."'",
52                                        "'".$pays."'",
53                                        "'".$region."'",       
54                                        "'".$ville."'",
55                                        '"adresse"',
56                                        '"fai" ',
57                                        $count + 1
58        );
59        ajout_ligne(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs, $valeurs,($count==0)) ;   
60 }
61 
62 break;
63 //================================================================================================
64  case 'raz':
65        $ip_black=str_replace('*',"%",$ip_black);
66                $query = "DELETE FROM `".MAIL_BLACK_LISTE_TABLE."` WHERE `ip` like '%".$ip_black."%'  ";
67                        pwg_query($query);
68   break;
69   
70    default:
71
72
73                               
74   break;
75   
76  } 
77//================ Liste Black liste =================
78  create_table(MAIL_BLACK_LISTE_TABLE,$superv_bl_champs,$superv_bl_type) ;
79
80  $query = "
81    SELECT *,  COUNT(`ip`) as total ,   `ip` as blacklist, `ip` as U_DELETE
82 
83    FROM ".MAIL_BLACK_LISTE_TABLE."
84                GROUP by ip
85        ;";
86        $liste_bl = array();
87    $result = pwg_query($query);
88                while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
89                        {
90                         array_push($liste_bl,$row);
91                                }
92//================ Liste IP ==============                     
93             $query = '
94    SELECT DISTINCT     H.`id`,
95        H.`date`,
96        H.`time`,
97        H.`user_id`,
98        H.`IP`,
99        COUNT(H.`IP`) as total 
100    FROM '.HISTORY_TABLE.'  AS H
101        WHERE H.`IP` not LIKE "'.$_SERVER['REMOTE_ADDR'].'"
102        ';//
103        if (count($liste_bl)>0)
104         {
105        $query .= '
106        AND  H.`IP` not IN (     SELECT `ip`
107    FROM '.MAIL_BLACK_LISTE_TABLE.' ) ';
108        }
109       
110        $query .= '
111       
112        GROUP by H.`IP` ;
113       
114        ;'  ;//
115        $result = pwg_query($query);
116        $liste_ip=array();
117        while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
118                        {
119                           array_push($liste_ip, $row);
120                                }
121                               
122
123
124
125
126
127
128?>
Note: See TracBrowser for help on using the repository browser.