Changeset 1590913
- Timestamp:
- 02/07/2017 12:58:08 PM (9 years ago)
- Location:
- tor-blocker-by-inazo
- Files:
-
- 97 added
- 3 edited
-
tags/1.1 (added)
-
tags/1.1/inazo.real.tor.blocker.php (added)
-
tags/1.1/netdns2-master (added)
-
tags/1.1/netdns2-master/LICENSE (added)
-
tags/1.1/netdns2-master/Net (added)
-
tags/1.1/netdns2-master/Net/DNS2 (added)
-
tags/1.1/netdns2-master/Net/DNS2.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/BitMap.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Cache (added)
-
tags/1.1/netdns2-master/Net/DNS2/Cache.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Cache/File.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Cache/Shm.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Exception.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Header.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Lookups.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Packet (added)
-
tags/1.1/netdns2-master/Net/DNS2/Packet.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Packet/Request.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Packet/Response.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/PrivateKey.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Question.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/A.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/AAAA.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/AFSDB.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/ANY.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/APL.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/ATMA.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/AVC.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/CAA.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/CDNSKEY.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/CDS.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/CERT.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/CNAME.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/CSYNC.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/DHCID.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/DLV.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/DNAME.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/DNSKEY.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/DS.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/EID.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/EUI48.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/EUI64.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/HINFO.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/HIP.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/IPSECKEY.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/ISDN.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/KEY.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/KX.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/L32.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/L64.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/LOC.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/LP.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/MX.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/NAPTR.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/NID.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/NIMLOC.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/NS.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/NSAP.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/NSEC.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/NSEC3.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/NSEC3PARAM.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/OPENPGPKEY.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/OPT.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/PTR.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/PX.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/RP.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/RRSIG.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/RT.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/SIG.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/SMIMEA.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/SOA.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/SPF.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/SRV.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/SSHFP.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/TA.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/TALINK.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/TKEY.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/TLSA.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/TSIG.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/TXT.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/URI.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/WKS.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/RR/X25.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Resolver.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Socket (added)
-
tags/1.1/netdns2-master/Net/DNS2/Socket.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Socket/Sockets.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Socket/Streams.php (added)
-
tags/1.1/netdns2-master/Net/DNS2/Updater.php (added)
-
tags/1.1/netdns2-master/README.md (added)
-
tags/1.1/netdns2-master/composer.json (added)
-
tags/1.1/netdns2-master/package.php (added)
-
tags/1.1/netdns2-master/package.xml (added)
-
tags/1.1/readme.txt (added)
-
tags/1.1/uninstall.php (added)
-
trunk/inazo.real.tor.blocker.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tor-blocker-by-inazo/trunk/inazo.real.tor.blocker.php
r1571760 r1590913 3 3 Plugin Name: Tor Blocker by Inazo 4 4 Description: This plugin blocks Tor users by preventing them from viewing your website. 5 Version: 1. 05 Version: 1.1 6 6 Author: Inazo 7 7 Author URI: https://www.kanjian.fr … … 35 35 function installPluginTor(){ 36 36 37 add_option( 'inazo.real.tor.blocker_db_version', '1.0' ); 37 if (! wp_next_scheduled ( 'inazo_tor_clean_logs' )) { 38 wp_schedule_event(time(), 'hourly', 'inazo_tor_clean_logs'); 39 } 40 41 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 42 43 44 $optionIsOk = get_option('inazo.real.tor.blocker_db_version'); 45 46 $currentVersion = '1.1'; 47 48 if( !$optionIsOk ){ 49 50 update_option( 'inazo.real.tor.blocker_db_version', $currentVersion ); 51 52 global $wpdb; 53 $table_name = $wpdb->prefix.'inazo_tor_logs'; 54 55 if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { 56 57 $sqlForCreateTable = 'CREATE TABLE '.$table_name.' ( 58 id_tor_inazo_log int(11) NOT NULL AUTO_INCREMENT, 59 ip_concern varchar(255) NOT NULL, 60 is_tor int(1) NOT NULL, 61 date_of_log datetime NOT NULL, 62 PRIMARY KEY id_tor_inazo_log (id_tor_inazo_log) 63 ) '.$wpdb->get_charset_collate().';'; 64 65 dbDelta( $sqlForCreateTable ); 66 } 67 } 68 else 69 add_option( 'inazo.real.tor.blocker_db_version', $currentVersion ); 70 71 global $wpdb; 72 $table_name = $wpdb->prefix.'inazo_tor_logs'; 73 74 if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { 75 76 $sqlForCreateTable = 'CREATE TABLE '.$table_name.' ( 77 id_tor_inazo_log int(11) NOT NULL AUTO_INCREMENT, 78 ip_concern varchar(255) NOT NULL, 79 is_tor int(1) NOT NULL, 80 date_of_log datetime NOT NULL, 81 PRIMARY KEY id_tor_inazo_log (id_tor_inazo_log) 82 ) '.$wpdb->get_charset_collate().';'; 83 84 dbDelta( $sqlForCreateTable ); 85 } 86 87 38 88 } 39 89 … … 91 141 } 92 142 143 function isInLog( $ip ){ 144 145 global $wpdb; 146 147 $toReturn = array( 'num_rows' => '', 'valeurs' => '' ); 148 149 $sql = $wpdb->prepare('SELECT is_tor FROM '.$wpdb->prefix.'inazo_tor_logs WHERE ip_concern = %s', $ip ); 150 $wpdb->query( $sql ); 151 152 $toReturn['num_rows'] = $wpdb->num_rows; 153 154 if( $wpdb->num_rows > 0 ) 155 $toReturn['valeurs'] = $wpdb->get_results($sql, ARRAY_A); 156 157 return $toReturn; 158 } 159 93 160 function checkIsTorConnexion(){ 94 161 162 global $wpdb; 163 95 164 $ip = $myIp = $myPort = 0; 96 165 … … 109 178 } 110 179 111 $isTor = torel_check($ip, $myPort, $myIp); 112 113 // use $istor as needed for altering page behavior: 114 if( $isTor < 0){ 115 } 116 else if ($isTor) { 117 118 echo '<strong>Connections from the Tor network are not allowed on this website.</strong>'; 119 wp_die(); 180 $returnsSql = isInLog( $ip ); 181 182 183 184 if( $returnsSql['num_rows'] > 0 ){ 185 186 if( $returnsSql['valeurs'][0]['is_tor'] == 1 ){ 187 188 echo '<strong>Connections from the Tor network are not allowed on this website.</strong>'; 189 wp_die(); 190 } 191 192 } 193 else{ 194 195 $isTor = torel_check($ip, $myPort, $myIp); 196 197 // use $istor as needed for altering page behavior: 198 if( $isTor < 0){ 199 200 201 $wpdb->insert( $wpdb->prefix.'inazo_tor_logs', array( 'ip_concern' => $ip, 'is_tor' => 0, 'date_of_log' => current_time('mysql', 1) ), array( '%s', '%d' ) ); 202 203 } 204 else if ($isTor) { 205 206 207 $wpdb->insert( $wpdb->prefix.'inazo_tor_logs', array( 'ip_concern' => $ip, 'is_tor' => 1, 'date_of_log' => current_time('mysql', 1) ), array( '%s', '%d' ) ); 208 echo '<strong>Connections from the Tor network are not allowed on this website.</strong>'; 209 wp_die(); 210 } 120 211 } 121 212 } 122 213 123 214 register_activation_hook( __FILE__, 'installPluginTor' ); 215 register_deactivation_hook(__FILE__, 'unactivatePlugin'); 216 217 function unactivatePlugin(){ 218 219 wp_clear_scheduled_hook('inazo_tor_clean_logs'); 220 } 124 221 125 222 add_action( 'setup_theme', 'checkIsTorConnexion' ); 223 224 add_action('inazo_tor_clean_logs', 'inazo_tor_clean_logs_task'); 225 226 function inazo_tor_clean_logs_task() { 227 228 global $wpdb; 229 230 $wpdb->query('DELETE FROM '.$wpdb->prefix.'inazo_tor_logs WHERE (TIMESTAMPDIFF(MINUTE, date_of_log, NOW()) / 60 ) >= 3'); 231 } -
tor-blocker-by-inazo/trunk/readme.txt
r1571791 r1590913 4 4 Tags: tor, security, tor blocker, ip block, ip blocker, ip 5 5 Requires at least: 4.5.1 6 Tested up to: 4.7 7 Stable tag: 1. 06 Tested up to: 4.7.2 7 Stable tag: 1.1 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 45 45 == CHANGELOG == 46 46 47 = 1.1 = 48 * adding table in database for caching IP results and increase performance 49 * add clear log tables every three hours 50 47 51 = 1.0 = 48 52 * init version -
tor-blocker-by-inazo/trunk/uninstall.php
r1571760 r1590913 10 10 11 11 delete_option('inazo.real.tor.blocker_db_version'); 12 12 13 global $wpdb; 14 $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'inazo_tor_logs'); 15 wp_clear_scheduled_hook('inazo_tor_clean_logs'); 13 16 ?>
Note: See TracChangeset
for help on using the changeset viewer.