Changeset 1400300
- Timestamp:
- 04/20/2016 12:27:44 PM (10 years ago)
- Location:
- querywall/trunk
- Files:
-
- 6 edited
-
core/class-qwall-admin.php (modified) (4 diffs)
-
core/class-qwall-core.php (modified) (1 diff)
-
core/class-qwall-monitor.php (modified) (2 diffs)
-
core/class-qwall-setup.php (modified) (2 diffs)
-
querywall.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
querywall/trunk/core/class-qwall-admin.php
r1262571 r1400300 23 23 * @return array 24 24 */ 25 public function build_admin() {25 public static function build_admin() { 26 26 27 27 global $plugin_file; … … 43 43 * @return array 44 44 */ 45 public function render_page() {45 public static function render_page() { 46 46 47 47 require( dirname( __FILE__ ) . '/class-qwall-monitor.php' ); 48 49 if ( $event_purge_next_run = wp_next_scheduled( 'qwall_purge_logs', 24 ) ) { 50 $event_purge_older_than = __( '24 hours', 'querywall' ); 51 } else if ( $event_purge_next_run = wp_next_scheduled( 'qwall_purge_logs', 48 ) ) { 52 $event_purge_older_than = __( '48 hours', 'querywall' ); 53 } else if ( $event_purge_next_run = wp_next_scheduled( 'qwall_purge_logs', 72 ) ) { 54 $event_purge_older_than = __( '72 hours', 'querywall' ); 55 } else if ( $event_purge_next_run = wp_next_scheduled( 'qwall_purge_logs', 0 ) ) { 56 $event_purge_older_than = '"' . __( 'the big bank', 'querywall' ) . '"'; 57 } else { 58 $event_purge_next_run = false; 59 $event_purge_older_than = false; 60 } 48 61 49 62 $fw_monitor = new QWall_Monitor(); … … 51 64 ?> 52 65 <style type="text/css"> 53 .wp-list-table .column-date_time { width: 10%; }54 .wp-list-table .column-date_time span { cursor: help; border-bottom: 1px dotted #aaa; }55 .wp-list-table .column-ipv4 { width: 10%; }56 .wp-list-table .column-filter_group { width: 10%; }57 .wp-list-table .column-filter_input { width: 70%; }66 .wp-list-table .column-date_time { width: 10%; } 67 .wp-list-table .column-date_time span { cursor: help; border-bottom: 1px dotted #aaa; } 68 .wp-list-table .column-ipv4 { width: 10%; } 69 .wp-list-table .column-filter_group { width: 10%; } 70 .wp-list-table .column-filter_input { width: 70%; } 58 71 .wp-list-table .column-filter_input strong { 59 72 padding: 0 2px; … … 62 75 background-color: #ffff8c; 63 76 } 64 .qwall-subtitle { margin: 5px 0 0; color: #666; } 77 #poststuff > p { margin: 5px 0 -20px; color: #666; } 78 #poststuff form > p { margin-bottom: 0; } 79 #poststuff form > p > span { cursor: help; border-bottom: 1px dotted #aaa; } 80 #poststuff input, 81 #poststuff select { vertical-align: baseline; } 65 82 </style> 66 <div class="wrap">83 <div id="poststuff" class="wrap"> 67 84 <h2><?php echo get_admin_page_title(); ?></h2> 68 <p class="qwall-subtitle">Blocked requests will be shown in the list below.</p> 85 <div class="postbox"> 86 <h3>Options</h3> 87 <div class="inside"> 88 <form method="post" action=""> 89 <?php wp_nonce_field( 'qwall_purge_logs', 'qwall_purge_logs_nonce' ); ?> 90 <?php _e( 'Clear logs older than', 'querywall' ); ?> 91 <select name="qwall_purge_logs_older_than"> 92 <option value="24"><?php _e( '24 hours', 'querywall' ); ?></option> 93 <option value="48"><?php _e( '48 hours', 'querywall' ); ?></option> 94 <option value="72"><?php _e( '72 hours', 'querywall' ); ?></option> 95 <option value="0"><?php _e( 'the big bang', 'querywall' ); ?></option> 96 </select> | 97 <input class="button-primary" type="submit" name="qwall_purge_logs_now" value="<?php _e( 'Clear now', 'querywall' ); ?>"> 98 <?php if ( $event_purge_next_run ) { ?> 99 <input class="button-primary" type="submit" name="qwall_purge_logs_unschedule" value="<?php _e( 'Unschedule', 'querywall' ); ?>"> 100 <?php } else { ?> 101 <input class="button-primary" type="submit" name="qwall_purge_logs_daily" value="<?php _e( 'Clear daily', 'querywall' ); ?>"> 102 <?php } ?> 103 <?php if ( $event_purge_next_run ) { ?> 104 <p><?php printf( __( 'Logs older than %s are scheduled to be purged in <span title="%s">%s</span>.', 'querywall' ), $event_purge_older_than, get_date_from_gmt( date( 'Y-m-d H:i:s', $event_purge_next_run ) ), human_time_diff( $event_purge_next_run, current_time( 'timestamp', 1 ) ) ); ?></p> 105 <?php } ?> 106 </form> 107 </div> 108 </div> 109 <p><?php _e( 'Blocked requests are shown in the list below.', 'querywall' ); ?></p> 69 110 <?php $fw_monitor->display(); ?> 70 111 </div> 71 112 <?php 113 } 114 115 /** 116 * Displays admin notice on success, error, warning, etc. 117 * 118 * @since 1.0.5 119 * @return array 120 */ 121 public static function render_admin_notice() { 122 ?> 123 <div class="notice notice-success is-dismissible"> 124 <p><?php _e( 'Success!', 'querywall' ); ?></p> 125 </div> 126 <?php 127 } 128 129 /** 130 * Purge blocked request logs. 131 * 132 * @since 1.0.5 133 * @return array 134 */ 135 public static function purge_logs( $older_than_hours = 0 ) { 136 137 global $wpdb; 138 139 if ( $older_than_hours == 0 ) { 140 $wpdb->query( "DELETE FROM `" . $wpdb->base_prefix . "qwall_monitor`;" ); 141 } else if( in_array( $older_than_hours, array( 24, 48, 72 ) ) ) { 142 $wpdb->query( "DELETE FROM `" . $wpdb->base_prefix . "qwall_monitor` WHERE `date_time_gmt` < '" . current_time( 'mysql', 1 ) . "' - INTERVAL " . esc_sql( ( int ) $older_than_hours ) . " HOUR;" ); 143 } 72 144 } 73 145 -
querywall/trunk/core/class-qwall-core.php
r1275328 r1400300 41 41 42 42 if ( is_admin() ) { 43 require_once( $dirname . '/class-qwall-setup.php' ); 44 require_once( $dirname . '/class-qwall-admin.php' ); 45 register_activation_hook( $plugin_file, array( 'QWall_Setup', 'on_activate' ) ); 46 register_deactivation_hook( $plugin_file, array( 'QWall_Setup', 'on_deactivate' ) ); 47 register_uninstall_hook( $plugin_file, array( 'QWall_Setup', 'on_uninstall' ) ); 48 add_action( 'activated_plugin', array( 'QWall_Setup', 'on_activated_plugin' ) ); 49 add_action( 'admin_menu', array( 'QWall_Admin', 'build_admin' ) ); 50 add_filter( 'plugin_row_meta', array( 'QWall_Admin', 'rate' ), 10, 2 ); 43 self::admin_init(); 44 } 45 } 46 47 /** 48 * Admin magic starts here. 49 * 50 * @since 1.0.5 51 * @return void 52 */ 53 public static function admin_init() { 54 55 $dirname = dirname( self::$settings['plugin_file'] ); 56 57 require_once( $dirname . '/core/class-qwall-util.php' ); 58 require_once( $dirname . '/core/class-qwall-setup.php' ); 59 require_once( $dirname . '/core/class-qwall-admin.php' ); 60 register_activation_hook( self::$settings['plugin_file'], array( 'QWall_Setup', 'on_activate' ) ); 61 register_deactivation_hook( self::$settings['plugin_file'], array( 'QWall_Setup', 'on_deactivate' ) ); 62 register_uninstall_hook( self::$settings['plugin_file'], array( 'QWall_Setup', 'on_uninstall' ) ); 63 add_action( 'activated_plugin', array( 'QWall_Setup', 'on_activated_plugin' ) ); 64 add_action( 'admin_menu', array( 'QWall_Admin', 'build_admin' ) ); 65 add_filter( 'plugin_row_meta', array( 'QWall_Admin', 'rate' ), 10, 2 ); 66 add_action( 'qwall_purge_logs', array( 'QWall_Admin', 'purge_logs' ) ); 67 68 if ( isset( $_POST['qwall_purge_logs_now'] ) ) { 69 70 require_once( ABSPATH . 'wp-includes/pluggable.php' ); 71 72 if ( wp_verify_nonce( $_POST['qwall_purge_logs_nonce'], 'qwall_purge_logs' ) ) { 73 74 do_action( 'qwall_purge_logs', ( int ) $_POST['qwall_purge_logs_older_than'] ); 75 add_action( 'admin_notices', array( 'QWall_Admin', 'render_admin_notice' ) ); 76 } 77 } 78 79 if ( isset( $_POST['qwall_purge_logs_daily'] ) || isset( $_POST['qwall_purge_logs_unschedule'] ) ) { 80 81 require_once( ABSPATH . 'wp-includes/pluggable.php' ); 82 83 if ( wp_verify_nonce( $_POST['qwall_purge_logs_nonce'], 'qwall_purge_logs' ) ) { 84 85 QWall_Util::unschedule_event( 'qwall_purge_logs' ); 86 87 if( isset( $_POST['qwall_purge_logs_daily'] ) ) { 88 wp_schedule_event( current_time( 'timestamp' ), 'daily', 'qwall_purge_logs', ( int ) $_POST['qwall_purge_logs_older_than'] ); 89 } 90 91 add_action( 'admin_notices', array( 'QWall_Admin', 'render_admin_notice' ) ); 92 } 51 93 } 52 94 } -
querywall/trunk/core/class-qwall-monitor.php
r1263584 r1400300 83 83 switch( $column_name ) { 84 84 case 'date_time': 85 return '<span title="' . $item[ 'date_time' ]. '">' . human_time_diff( $item[ 'time_stamp'], current_time( 'timestamp' ) ) . ' ago';85 return '<span title="' . $item['date_time'] . '">' . human_time_diff( $item['time_stamp'], current_time( 'timestamp' ) ) . ' ago'; 86 86 case 'ipv4': 87 87 return long2ip( $item[ $column_name ] ); 88 88 case 'filter_input': 89 return preg_replace( '/'. preg_quote( $item[ 'filter_match' ], '/' ) .'/i', '<strong>\\0</strong>', $item[ 'filter_input' ] ); 90 89 return preg_replace( '/' . preg_quote( $item['filter_match'], '/' ) . '/i', '<strong>\\0</strong>', $item['filter_input'] ); 91 90 default: 92 91 return $item[ $column_name ]; … … 113 112 114 113 $count = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->base_prefix . "qwall_monitor` " . $extra_sql . ";" ); 115 $items = $wpdb->get_results( "SELECT date_time, UNIX_TIMESTAMP(date_time) AS time_stamp, ipv4, filter_group, filter_match, filter_input FROM `" . $wpdb->base_prefix . "qwall_monitor` " . $extra_sql . " LIMIT " . absint( $offset ) . ", " . absint( $limit ) . ";", ARRAY_A );114 $items = $wpdb->get_results( "SELECT date_time, UNIX_TIMESTAMP(date_time) AS time_stamp, ipv4, filter_group, filter_match, filter_input FROM `" . $wpdb->base_prefix . "qwall_monitor` " . $extra_sql . " LIMIT " . absint( $offset ) . ", " . absint( $limit ) . ";", ARRAY_A ); 116 115 117 116 return $items; -
querywall/trunk/core/class-qwall-setup.php
r1275328 r1400300 42 42 public static function on_uninstall() { 43 43 self::remove_database_tables(); 44 self::remove_scheduled_events(); 44 45 } 45 46 … … 107 108 108 109 /** 110 * Unschedule all events 111 * 112 * @since 1.0.5 113 * @return void 114 */ 115 private static function remove_scheduled_events() { 116 117 QWall_Util::unschedule_event( 'qwall_purge_logs' ); 118 } 119 120 /** 109 121 * Make sure plugin loads first 110 122 * -
querywall/trunk/querywall.php
r1382896 r1400300 6 6 * Tags: Tags: firewall, security, protect, block, antivirus, defender, malicious, request, query, blacklist, url, eval, base64, hack, attack, brute force, infection, injection, malware, prevention, protection, trojan, virus, xss, waf 7 7 * Usage: No configuration needed, just activate it. 8 * Version: 1.0. 48 * Version: 1.0.5 9 9 * Author: 4ley 10 10 * Author URI: https://github.com/4ley/querywall -
querywall/trunk/readme.txt
r1382896 r1400300 47 47 == Changelog == 48 48 49 = 1.0.5 = 50 51 * Clear logs now and periodically added 52 53 = 1.0.4 = 54 55 * WordPress compatibility test 56 49 57 = 1.0.3 = 50 58
Note: See TracChangeset
for help on using the changeset viewer.