source: extensions/HistoryIPExcluder/admin/HIPE_admin.php @ 31930

Last change on this file since 31930 was 27445, checked in by Eric, 10 years ago

Next version is 2.6.1 :
Fix obsolete is_adviser()

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