Skip to content

Commit

Permalink
Merge pull request #138 from thiagolcks/Issue-135
Browse files Browse the repository at this point in the history
Validate the IP and sanitize a query - Issue #135
  • Loading branch information
Ben Marshall committed Nov 19, 2016
2 parents ab7b441 + 269ac79 commit 2177923
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/helpers.php
Expand Up @@ -46,7 +46,8 @@ function zerospam_get_ip() {
$ipaddress = getenv('HTTP_FORWARDED');
} else if ( getenv('REMOTE_ADDR') ) {
$ipaddress = getenv('REMOTE_ADDR');
} else {
}
if ( false === WP_Http::is_ip_address( $ipaddress ) ) {
$ipaddress = 'UNKNOWN';
}

Expand Down Expand Up @@ -135,7 +136,7 @@ function zerospam_is_blocked( $ip ) {
function zerospam_get_blocked_ip( $ip ) {
global $wpdb;
$table_name = $wpdb->prefix . 'zerospam_blocked_ips';
$query = $wpdb->get_row( "SELECT * FROM $table_name WHERE ip = '" . $ip . "'" );
$query = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE ip = %s", $ip ) );

if ( null == $query ) {
return false;
Expand Down Expand Up @@ -488,7 +489,7 @@ function zerospam_plugin_check( $plugin ) {
case 'wpf':
if ( is_plugin_active( 'wpforms/wpforms.php' ) || is_plugin_active( 'wpforms-lite/wpforms.php' ) ) {
$result = true;
}
}
break;
}

Expand Down

0 comments on commit 2177923

Please sign in to comment.