calvin_42
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: New hack with file “temp-crawl.php”FYI, same problem happened on my website.
The php file uploaded in wp-content/uploads was using the script https://pastebin.com/raw/jmxnY3Rk that includes a JS script in all posts via a MySQL query.
Forum: Plugins
In reply to: Bug fix: wpdb insert & update with null valuesThere is a small bug in your code, you forgot to do an array_shift in your block “$data[$field]===null”.
Here is a the correct insert function. Do the same for the update function.
function insert($table, $data, $format = null) {
$formats = $format = (array) $format;
$fields = array_keys($data);
$formatted_fields = array();
$real_data = array();
foreach ( $fields as $field ) {
if ( !empty($format) )
$form = ( $form = array_shift($formats) ) ? $form : $format[0];
elseif ( isset($this->field_types[$field]) )
$form = $this->field_types[$field];
else
$form = ‘%s’;if ($data[$field]===null) {
$formatted_fields[] = ‘NULL’;
}
else {
$formatted_fields[] = “‘”.$form.”‘”;
$real_data[] = $data[$field];
}
}
$sql = “INSERT INTO$table(" . implode( ',', $fields ) . ") VALUES (” . implode( “,”, $formatted_fields ) . “)”;
return $this->query( $this->prepare( $sql, $real_data) );
}Forum: Plugins
In reply to: Bug fix: wpdb insert & update with null valuesThanks for sharing. Very useful.
Should be included in core.