[5099] | 1 | <?php |
---|
| 2 | |
---|
| 3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 4 | |
---|
| 5 | load_language('plugin.lang', HIPE_PATH); |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | $ip_geolocalisation1 = '<a href="http://www.geoiptool.com/fr/?IP='; |
---|
[5113] | 9 | $ip_geolocalisation2 = '" title="Geo IP localisation" target="_blank"><img src="'.HIPE_PATH.'/geoip.ico" class="button" alt="'.l10n('IP_geolocalisation').'"></a>'; |
---|
[5099] | 10 | |
---|
| 11 | $ip_ripe1 = '<a href="http://www.ripe.net/whois?form_type=simple&full_query_string=&searchtext='; |
---|
| 12 | $ip_ripe2 = '+&do_search=Search" title="Ripe Whois" target="_blank">'; |
---|
| 13 | $ip_ripe3 = '</a>'; |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | if ( 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 | |
---|
[5162] | 23 | $conf['HistoryIPExcluder'] = stripslashes($v); |
---|
[5113] | 24 | |
---|
[5099] | 25 | $query = ' |
---|
| 26 | UPDATE '.CONFIG_TABLE.' |
---|
[5162] | 27 | SET value="'.$conf['HistoryIPExcluder'].'" |
---|
| 28 | WHERE param="HistoryIPExcluder" |
---|
[5099] | 29 | LIMIT 1'; |
---|
| 30 | pwg_query($query); |
---|
| 31 | |
---|
| 32 | // information message |
---|
[5113] | 33 | array_push($page['infos'], l10n('HIPE_save_config')); |
---|
[5099] | 34 | } |
---|
| 35 | elseif ( isset($_POST['CleanHist']) ) |
---|
| 36 | { |
---|
[5162] | 37 | $conf_HIPE = explode("," , $conf['HistoryIPExcluder']); |
---|
[5099] | 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 |
---|
[5113] | 58 | array_push($page['infos'], l10n('HIPE_hist_cleaned')); |
---|
[5099] | 59 | } |
---|
| 60 | elseif ( isset($_POST['HIPE_IPByMember']) ) |
---|
| 61 | { |
---|
| 62 | $template->assign( |
---|
| 63 | array( |
---|
[5113] | 64 | 'HIPE_DESCRIPTION2' => l10n('HIPE_IPByMember_description'), |
---|
[5099] | 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 | } |
---|
| 92 | elseif ( 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 | } |
---|
| 132 | elseif ( 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 | } |
---|
| 165 | elseif ( 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 | |
---|
[5162] | 199 | $conf_HIPE = explode("," , $conf['HistoryIPExcluder']); |
---|
[5099] | 200 | |
---|
| 201 | $template->assign( |
---|
| 202 | array( |
---|
[5162] | 203 | 'HIPE_F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=plugin§ion=HistoryIPExcluder%2Fadmin%2FHIPE_admin.php', |
---|
[5113] | 204 | 'IPs_EXCLUDED' => implode("\n", $conf_HIPE), |
---|
[5099] | 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 | |
---|
[5121] | 211 | ?> |
---|