Skip to content

Commit a0a390a

Browse files
committed
CF7_AntiSpam_Filters fixed $wpdb->prepare
1 parent c5f6ce6 commit a0a390a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/CF7_AntiSpam_Filters.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static function cf7a_blacklist_get_ip( $ip ) {
9090
$ip = filter_var( $ip, FILTER_VALIDATE_IP );
9191
if ( $ip ) {
9292
global $wpdb;
93-
$r = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}cf7a_blacklist WHERE ip = %s", $ip ) );
93+
$r = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM %s WHERE ip = %s", $wpdb->prefix . 'cf7a_blacklist', $ip ) );
9494
if ( $r ) {
9595
return $r;
9696
}
@@ -110,7 +110,7 @@ public function cf7a_blacklist_get_id( $id ) {
110110
if ( is_int( $id ) ) {
111111
global $wpdb;
112112

113-
return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}cf7a_blacklist WHERE id = %s", $id ) );
113+
return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM %s WHERE id = %s", $wpdb->prefix . 'cf7a_blacklist', $id ) );
114114
}
115115
}
116116

@@ -153,7 +153,7 @@ public function cf7a_ban_by_ip( string $ip, array $reason = array(), $spam_score
153153
),
154154
),
155155
array( '%s', '%d', '%s' )
156-
);
156+
); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
157157

158158
if ( $r > - 1 ) {
159159
return true;
@@ -184,7 +184,7 @@ public function cf7a_unban_by_ip( $ip ) {
184184
array(
185185
'%s',
186186
)
187-
);
187+
); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
188188

189189
return ! is_wp_error( $r ) ? $r : $wpdb->last_error;
190190
}
@@ -212,7 +212,7 @@ public function cf7a_unban_by_id( $id ) {
212212
array(
213213
'%d',
214214
)
215-
);
215+
); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
216216

217217
return ! is_wp_error( $r ) ? $r : $wpdb->last_error;
218218
}
@@ -239,11 +239,11 @@ public function cf7a_cron_unban() {
239239
$lower_bound = 0;
240240

241241
/* removes a status count at each balcklisted ip */
242-
$updated = $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}cf7a_blacklist SET `status` = `status` - %d WHERE 1", $status_decrement ) );
242+
$updated = $wpdb->query( $wpdb->prepare( "UPDATE %s SET `status` = `status` - %d WHERE 1", $wpdb->prefix . 'cf7a_blacklist', $status_decrement ) );
243243
cf7a_log( "Status updated for blacklisted (score -1) - $updated users", 1 );
244244

245245
/* when the line has 0 in status, we can remove it from the blacklist */
246-
$updated = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}cf7a_blacklist WHERE `status` = %d", $lower_bound ) );
246+
$updated = $wpdb->query( $wpdb->prepare( "DELETE FROM %s WHERE `status` = %d", $wpdb->prefix . 'cf7a_blacklist', $lower_bound ) );
247247
cf7a_log( "Removed $updated users from blacklist", 1 );
248248

249249
return true;

0 commit comments

Comments
 (0)