source: extensions/HistoryIPExcluder/branches/2.0/admin/HIPE_admin.php @ 13439

Last change on this file since 13439 was 5131, checked in by Eric, 15 years ago

[nbc_HistoryIPExcluder] Merged from trunk to branch 2.0

  • Property svn:eol-style set to LF
File size: 5.3 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5load_language('plugin.lang', HIPE_PATH);
6
7
8$ip_geolocalisation1 = '<a href="http://www.geoiptool.com/fr/?IP=';
9$ip_geolocalisation2 = '" title="Geo IP localisation" target="_blank"><img src="'.HIPE_PATH.'/geoip.ico" class="button" alt="'.l10n('IP_geolocalisation').'"></a>';
10
11$ip_ripe1 = '<a href="http://www.ripe.net/whois?form_type=simple&amp;full_query_string=&amp;searchtext=';
12$ip_ripe2 = '+&amp;do_search=Search" title="Ripe Whois" target="_blank">';
13$ip_ripe3 = '</a>';
14
15
16
17if ( isset($_POST['submit']) and !is_adviser() )
18{
19  $v = $_POST['HIPE_IPs_Excluded'];
20  $v = str_replace( "\r\n", ",", $v );
21  $v = str_replace( ",,", ",", $v );
22
23  $conf['nbc_HistoryIPExcluder'] = stripslashes($v);
24
25  $query = '
26    UPDATE '.CONFIG_TABLE.'
27    SET value="'.$conf['nbc_HistoryIPExcluder'].'"
28    WHERE param="nbc_HistoryIPExcluder"
29    LIMIT 1';
30  pwg_query($query);
31
32  // information message
33  array_push($page['infos'], l10n('HIPE_save_config'));
34}
35elseif ( isset($_POST['CleanHist']) )
36{
37  $conf_HIPE = explode("," , $conf['nbc_HistoryIPExcluder']);
38
39  foreach ( $conf_HIPE as $Exclusion )
40  {
41    $query = '
42      delete FROM '.HISTORY_TABLE.' where
43      IP like \''.$Exclusion.'\';';
44    pwg_query($query);
45   }
46
47
48  $query = '
49    truncate '.HISTORY_SUMMARY_TABLE.';';
50  pwg_query($query);
51
52  $query = '
53    UPDATE '.HISTORY_TABLE.'
54    SET summarized = \'false\';';
55  pwg_query($query);
56
57  // information message
58  array_push($page['infos'], l10n('HIPE_hist_cleaned'));
59}
60elseif ( isset($_POST['HIPE_IPByMember']) )
61{
62  $template->assign(
63    array(
64      'HIPE_DESCRIPTION2' => l10n('HIPE_IPByMember_description'),
65    )
66  );
67
68  $query = '
69    select distinct h.ip, u.username
70    from '.HISTORY_TABLE.' as h
71    inner join '.USERS_TABLE.' as u on u.id = h.user_id
72    where h.user_id <> 2
73    order by h.ip
74  ;';
75 
76  $subresult = pwg_query($query);
77
78  while ($subrow = mysql_fetch_array($subresult))
79  {
80    $template->assign(
81      'resultat',
82      array(
83        'HIPE_RESULTAT1' => $ip_geolocalisation1.$subrow['ip'].$ip_geolocalisation2.' '.$ip_ripe1.$subrow['ip'].$ip_ripe2.$subrow['ip'].$ip_ripe3,
84        'HIPE_RESULTAT2' => $subrow['username'],
85      )
86    );   
87  }
88
89  // information message
90  array_push($page['infos'], l10n('HIPE_resquet_ok'));
91}
92elseif ( isset($_POST['HIPE_OnlyGuest']) )
93{
94  $template->assign(
95    array(
96      'HIPE_DESCRIPTION2' => l10n('HIPE_OnlyGuest_description'),
97    )
98  );
99
100  $query1 = '
101    select distinct h.ip
102    from '.HISTORY_TABLE.' as h
103    where h.user_id <> 2
104  ;';
105 
106  $IPsMember = array_from_query($query1, 'ip');
107
108  $query = '
109    select h.ip, count(h.ip) as nbreIP
110    from '.HISTORY_TABLE.' as h
111    where h.ip not in (\''.implode('\',\'', $IPsMember).'\')
112    group by h.ip
113    order by nbreIP desc
114  ;';
115 
116  $subresult = pwg_query($query);
117
118  while ($subrow = mysql_fetch_array($subresult))
119  {
120    $template->assign(
121      'resultat',
122      array(
123        'HIPE_RESULTAT1' => $ip_geolocalisation1.$subrow['ip'].$ip_geolocalisation2.' '.$ip_ripe1.$subrow['ip'].$ip_ripe2.$subrow['ip'].$ip_ripe3,
124        'HIPE_RESULTAT2' => $subrow['nbreIP'],
125      )
126    );   
127  }
128
129  // information message
130  array_push($page['infos'], l10n('HIPE_resquet_ok'));
131}
132elseif ( isset($_POST['HIPE_IPForMember']) and isset($_POST['HIPE_input']))
133{
134  $template->assign(
135    array(
136      'HIPE_DESCRIPTION2' => l10n('HIPE_IPForMember_description'),
137    )
138  );
139
140  $query = '
141    select h.ip, u.username
142    from '.HISTORY_TABLE.' as h
143    inner join '.USERS_TABLE.' as u on u.id = h.user_id
144    where u.username like \''.$_POST['HIPE_input'].'\'
145    group by h.ip
146    order by h.ip
147  ;';
148 
149  $subresult = pwg_query($query);
150
151  while ($subrow = mysql_fetch_array($subresult))
152  {
153    $template->assign(
154      'resultat',
155      array(
156        'HIPE_RESULTAT1' => $subrow['username'],
157        'HIPE_RESULTAT2' => $ip_geolocalisation1.$subrow['ip'].$ip_geolocalisation2.' '.$ip_ripe1.$subrow['ip'].$ip_ripe2.$subrow['ip'].$ip_ripe3,
158      )
159    );   
160  }
161
162  // information message
163  array_push($page['infos'], l10n('HIPE_resquet_ok'));
164}
165elseif ( isset($_POST['HIPE_MemberForIp']) and isset($_POST['HIPE_input']))
166{
167  $template->assign(
168    array(
169      'HIPE_DESCRIPTION2' => l10n('HIPE_MemberForIp_description'),
170    )
171  );
172
173  $query = '
174    select h.ip, u.username
175    from '.HISTORY_TABLE.' as h
176    inner join '.USERS_TABLE.' as u on u.id = h.user_id
177    where h.ip like \''.$_POST['HIPE_input'].'\'
178    group by u.username
179    order by u.username
180  ;';
181 
182  $subresult = pwg_query($query);
183
184  while ($subrow = mysql_fetch_array($subresult))
185  {
186    $template->assign(
187      'resultat',
188      array(
189        'HIPE_RESULTAT1' => $ip_geolocalisation1.$subrow['ip'].$ip_geolocalisation2.' '.$ip_ripe1.$subrow['ip'].$ip_ripe2.$subrow['ip'].$ip_ripe3,
190        'HIPE_RESULTAT2' => $subrow['username'],
191      )
192    );   
193  }
194
195  // information message
196  array_push($page['infos'], l10n('HIPE_resquet_ok'));
197}
198
199$conf_HIPE = explode("," , $conf['nbc_HistoryIPExcluder']);
200
201$template->assign(
202  array(
203    'HIPE_F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=plugin&section=nbc_HistoryIPExcluder%2Fadmin%2FHIPE_admin.php',
204    'IPs_EXCLUDED' => implode("\n", $conf_HIPE),
205  )
206);
207
208  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/HIPE_admin.tpl');
209  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
210
211?>
Note: See TracBrowser for help on using the repository browser.