- Timestamp:
- 04/28/2016 05:57:12 PM (10 years ago)
- Location:
- querywall/trunk
- Files:
-
- 3 added
- 8 edited
-
LICENSE (added)
-
core/class-qwall-admin.php (modified) (5 diffs)
-
core/class-qwall-core.php (modified) (4 diffs)
-
core/class-qwall-dic.php (added)
-
core/class-qwall-firewall.php (modified) (6 diffs)
-
core/class-qwall-monitor.php (modified) (1 diff)
-
core/class-qwall-notice.php (modified) (2 diffs)
-
core/class-qwall-settings.php (added)
-
core/class-qwall-setup.php (modified) (2 diffs)
-
querywall.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
querywall/trunk/core/class-qwall-admin.php
r1402118 r1406697 16 16 17 17 /** 18 * Enqueue actions to build the admin pages.18 * Magic starts here. 19 19 * 20 * Calls all the needed actions to build any given admin page. 20 * All custom functionality will be hooked into the "init" action. 21 * 22 * @since 1.0.7 23 * @return void 24 */ 25 public function __construct() { 26 add_action( 'init', array( $this, 'init' ), 30 ); 27 } 28 29 /** 30 * Conditionally hook into WordPress. 31 * 32 * @since 1.0.7 33 * @return void 34 */ 35 public function init() { 36 37 add_action( 'admin_menu', array( $this, 'cb_admin_menu' ) ); 38 add_filter( 'plugin_row_meta', array( $this, 'cb_plugin_meta' ), 10, 2 ); 39 add_action( 'qwall_purge_logs', array( $this, 'purge_logs' ) ); 40 } 41 42 /** 43 * Enqueue actions to build the admin menu. 44 * 45 * Calls all the needed actions to build the admin menu. 21 46 * 22 47 * @since 1.0.1 23 48 * @return void 24 49 */ 25 public static function build_admin() {50 public function cb_admin_menu() { 26 51 27 global $plugin_file; 28 52 // add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); 29 53 add_menu_page( 30 54 __( 'Firewall Request Monitor', 'querywall' ), … … 32 56 'manage_options', 33 57 'querywall', 34 array( __CLASS__, 'render_page' ),58 array( $this, 'display_monitor_page' ), 35 59 'dashicons-shield' 60 ); 61 62 // add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); 63 add_submenu_page( 64 'querywall', 65 __( 'Firewall Request Monitor', 'querywall' ), 66 __( 'Monitor', 'querywall' ), 67 'manage_options', 68 'querywall', 69 array( $this, 'display_monitor_page' ) 36 70 ); 37 71 } 38 72 39 73 /** 40 * Displays firewall logs table74 * Displays firewall request monitor page 41 75 * 42 76 * @since 1.0.1 43 77 * @return void 44 78 */ 45 public static function render_page() {79 public function display_monitor_page() { 46 80 47 81 require( dirname( __FILE__ ) . '/class-qwall-monitor.php' ); … … 124 158 125 159 /** 126 * Displays admin notice on success, error, warning, etc.127 *128 * @since 1.0.5129 * @return void130 */131 public static function render_admin_notice( $message, $css_classes = 'notice-success is-dismissible' ) {132 ?>133 <div class="notice <?php echo $css_classes; ?>">134 <p><?php echo $message; ?></p>135 </div>136 <?php137 }138 139 /**140 160 * Purge blocked request logs. 141 161 * … … 143 163 * @return int|boolen 144 164 */ 145 public staticfunction purge_logs( $older_than_hours = 0 ) {165 public function purge_logs( $older_than_hours = 0 ) { 146 166 147 167 global $wpdb; … … 159 179 * Add rating link to plugin page. 160 180 * 161 * @since 1.0. 1181 * @since 1.0.7 162 182 * @return array 163 183 */ 164 public static function rate( $links, $file ) { 184 public function cb_plugin_meta( $links, $file ) { 185 165 186 if ( strpos( $file, 'querywall.php' ) !== false ) { 166 $wp_url = 'https://wordpress.org/support/view/plugin-reviews/querywall?rate=5#postform';167 $ fb_url = 'https://www.facebook.com/querywall';168 $links[] = '<a target="_blank" href=" ' . $wp_url . '" title="Rate and review QueryWall on WordPress.org">Rate this plugin</a>';169 $links[] = '<a target="_blank" href=" ' . $fb_url . '" title="Visit QueryWall on Facebook" style="padding:0 5px;color:#fff;vertical-align:middle;border-radius:2px;background:#f5c140;">Visit on Facebook</a>';187 // style="padding:0 2px;color:#fff;vertical-align:middle;border-radius:2px;background:#00b9eb;" 188 $links[] = '<a target="_blank" href="https://wordpress.org/support/view/plugin-reviews/querywall?rate=5#postform" title="Rate and review QueryWall on WordPress.org">Rate on WordPress.org</a>'; 189 $links[] = '<a target="_blank" href="https://github.com/4ley/querywall" title="Contribute to QueryWall on GitHub">Contribute on GitHub</a>'; 190 $links[] = '<a target="_blank" href="https://www.facebook.com/querywall" title="Visit QueryWall on Facebook">Visit on Facebook</a>'; 170 191 } 192 171 193 return $links; 172 194 } 173 195 } 174 196 197 QWall_DIC::set( 'admin', new QWall_Admin() ); 198 175 199 endif; -
querywall/trunk/core/class-qwall-core.php
r1402118 r1406697 30 30 public static function init( $plugin_file ) { 31 31 32 $dirname = dirname( __FILE__ );33 34 32 self::$settings = array( 35 33 'plugin_file' => $plugin_file, … … 37 35 ); 38 36 39 require_once( $dirname . '/class-qwall-firewall.php' ); 40 QWall_Firewall::init(); 37 $dirname = dirname( self::$settings['plugin_file'] ); 38 39 require_once( $dirname . '/core/class-qwall-dic.php' ); 40 require_once( $dirname . '/core/class-qwall-settings.php' ); 41 require_once( $dirname . '/core/class-qwall-firewall.php' ); 41 42 42 43 if ( is_admin() ) { … … 59 60 require_once( $dirname . '/core/class-qwall-notice.php' ); 60 61 require_once( $dirname . '/core/class-qwall-admin.php' ); 62 61 63 register_activation_hook( self::$settings['plugin_file'], array( 'QWall_Setup', 'on_activate' ) ); 62 64 register_deactivation_hook( self::$settings['plugin_file'], array( 'QWall_Setup', 'on_deactivate' ) ); 63 65 register_uninstall_hook( self::$settings['plugin_file'], array( 'QWall_Setup', 'on_uninstall' ) ); 64 66 add_action( 'activated_plugin', array( 'QWall_Setup', 'on_activated_plugin' ) ); 65 add_action( 'admin_menu', array( 'QWall_Admin', 'build_admin' ) );66 add_filter( 'plugin_row_meta', array( 'QWall_Admin', 'rate' ), 10, 2 );67 add_action( 'qwall_purge_logs', array( 'QWall_Admin', 'purge_logs' ) );68 67 69 68 if ( isset( $_POST['qwall_purge_logs_now'] ) ) { … … 73 72 if ( wp_verify_nonce( $_POST['qwall_purge_logs_nonce'], 'qwall_purge_logs' ) ) { 74 73 75 $affected_rows = QWall_ Admin::purge_logs( ( int ) $_POST['qwall_purge_logs_older_than'] );74 $affected_rows = QWall_DIC::get( 'admin' )->purge_logs( ( int ) $_POST['qwall_purge_logs_older_than'] ); 76 75 77 76 if ( false === $affected_rows ) { -
querywall/trunk/core/class-qwall-firewall.php
r1278466 r1406697 30 30 31 31 /** 32 * Magic starts here 32 * Magic starts here. 33 33 * 34 * @since 1.0.1 34 * All custom functionality will be hooked into the "plugins_loaded" action. 35 * 36 * @since 1.0.7 35 37 * @return void 36 38 */ 37 public static function init() { 39 public function __construct() { 40 add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) ); 41 } 42 43 /** 44 * Conditionally hook into WordPress. 45 * 46 * @since 1.0.7 47 * @return void 48 */ 49 public function plugins_loaded() { 50 51 if ( is_user_logged_in() && QWall_DIC::get( 'settings' )->get( 'settings', 'disable_loggedin_users' ) ) { 52 return null; 53 } 54 55 self::analyze(); 56 } 57 58 /** 59 * Analyze request 60 * 61 * @since 1.0.7 62 * @return void 63 */ 64 private static function analyze() { 38 65 39 66 // Analyze server variable … … 85 112 86 113 /** 87 * You shall not pass 114 * You shall not pass! 88 115 * 89 116 * @since 1.0.1 … … 92 119 private static function close() { 93 120 94 header('HTTP/1.1 403 Forbidden'); 95 header('Status: 403 Forbidden'); 96 header('Connection: Close'); 121 $qwall_settings = QWall_DIC::get( 'settings' ); 122 $redirect_url = $qwall_settings->get( 'settings', 'redirect_url' ); 123 $http_status_code = $qwall_settings->get( 'settings', 'http_status_code' ); 124 $server_response = $qwall_settings->get( 'settings', 'server_response' ); 125 126 if ( empty( $redirect_url ) ) { 127 128 if( ! isset( $_SERVER['SERVER_PROTOCOL'] ) || empty( $_SERVER['SERVER_PROTOCOL'] ) ) { 129 $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; 130 } 131 132 $http_status_code_message = QWall_DIC::get( 'settings' )->get_http_status_codes( $http_status_code ); 133 134 header( $_SERVER['SERVER_PROTOCOL'] . ' ' . $http_status_code_message, true, $http_status_code); 135 header( 'Connection: Close' ); 136 } else { 137 header('Location: ' . $redirect_url, true, $http_status_code); 138 } 139 140 if( ! empty( $server_response ) ) { 141 exit( $server_response ); 142 } 143 97 144 exit; 98 145 } … … 112 159 global $wpdb; 113 160 161 if( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { 162 $user_agent = $_SERVER['HTTP_USER_AGENT']; 163 } else { 164 $user_agent = ''; 165 } 166 167 if ( QWall_DIC::get( 'settings' )->get( 'settings', 'anonymize_ip' ) ) { 168 $ipv4 = long2ip( ip2long( $_SERVER['REMOTE_ADDR'] ) & 0xFFFFFF00 ); 169 } else { 170 $ipv4 = $_SERVER['REMOTE_ADDR']; 171 } 172 114 173 $wpdb->insert( 115 174 $wpdb->base_prefix . 'qwall_monitor', … … 117 176 'date_time' => current_time( 'mysql' ), 118 177 'date_time_gmt' => current_time( 'mysql', 1 ), 119 'ipv4' => sprintf( '%u', ip2long( $ _SERVER['REMOTE_ADDR']) ),120 'agent' => $ _SERVER['HTTP_USER_AGENT'],178 'ipv4' => sprintf( '%u', ip2long( $ipv4 ) ), 179 'agent' => $user_agent, 121 180 'filter_group' => $filter_group, 122 181 'filter_match' => $filter_match, … … 127 186 } 128 187 188 QWall_DIC::set( 'firewall', new QWall_Firewall() ); 189 129 190 endif; -
querywall/trunk/core/class-qwall-monitor.php
r1400300 r1406697 85 85 return '<span title="' . $item['date_time'] . '">' . human_time_diff( $item['time_stamp'], current_time( 'timestamp' ) ) . ' ago'; 86 86 case 'ipv4': 87 return long2ip( $item[ $column_name ] ); 87 88 $ipv4 = long2ip( $item[ $column_name ] ); 89 90 if ( substr( $ipv4, -2 ) == '.0' ) { 91 $ipv4 = substr_replace( $ipv4, '***', -1 ); 92 } 93 94 return $ipv4; 95 88 96 case 'filter_input': 89 97 return preg_replace( '/' . preg_quote( $item['filter_match'], '/' ) . '/i', '<strong>\\0</strong>', $item['filter_input'] ); -
querywall/trunk/core/class-qwall-notice.php
r1402118 r1406697 42 42 } 43 43 44 add_action( 'admin_notices', array( $this, ' render_admin_notice' ) );44 add_action( 'admin_notices', array( $this, 'display_admin_notice' ) ); 45 45 } 46 46 … … 51 51 * @return void 52 52 */ 53 public function render_admin_notice() {53 public function display_admin_notice() { 54 54 ?> 55 55 <div class="<?php echo implode( ' ', $this->css_classes ); ?>"> -
querywall/trunk/core/class-qwall-setup.php
r1400300 r1406697 41 41 */ 42 42 public static function on_uninstall() { 43 44 self::remove_options(); 43 45 self::remove_database_tables(); 44 46 self::remove_scheduled_events(); … … 119 121 120 122 /** 123 * Remove plugin options 124 * 125 * @since 1.0.7 126 * @return void 127 */ 128 private static function remove_options() { 129 130 QWall_DIC::get( 'settings' )->delete( 'settings' ); 131 } 132 133 /** 121 134 * Make sure plugin loads first 122 135 * -
querywall/trunk/querywall.php
r1402118 r1406697 6 6 * Tags: firewall, security, protect, block, antivirus, defender, malicious, request, query, blacklist, url, eval, base64, hack, attack, brute force, infection, injection, malware, botnet, backdoor, web application firewall, xss, website security, wordpress security, secure, prevention, protection, trojan, virus, xss, waf, security audit, querywall, bbq, block bad queries, ninjafirewall, wordfence, bulletproof security, ithemes security, better wp security, sucuri, vaultpress, simple firewall 7 7 * Usage: No configuration needed, just activate it. 8 * Version: 1.0. 68 * Version: 1.0.7 9 9 * Author: 4ley 10 10 * Author URI: https://github.com/4ley/querywall -
querywall/trunk/readme.txt
r1402118 r1406697 25 25 * Upload, activate, ready and done 26 26 * Works in background 27 * Identifies and forbids a wide range of malicious queries including [5G/6G Blacklist](https://perishablepress.com/6g-beta/)27 * Identifies and forbids a wide range of malicious queries 28 28 29 29 **Contribution / Social** … … 46 46 47 47 == Changelog == 48 49 = 1.0.7 = 50 51 * Options added: Disable for logged in users, Anonymize IP addresses, Server status code, Redirect URL, Server response 52 53 = 1.0.6 = 54 55 * Minor fixes 48 56 49 57 = 1.0.5 =
Note: See TracChangeset
for help on using the changeset viewer.