Ticket #6644: prepared_queries5.diff
| File prepared_queries5.diff, 3.4 KB (added by , 18 years ago) |
|---|
-
xmlrpc.php
1352 1352 if( is_array( $attachments ) ) { 1353 1353 foreach( $attachments as $file ) { 1354 1354 if( strpos( $post_content, $file->guid ) !== false ) { 1355 $wpdb->query( "UPDATE {$wpdb->posts} SET post_parent = '$post_ID' WHERE ID = '{$file->ID}'");1355 $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_parent = %d WHERE ID = %d", $post_ID, $file->ID) ); 1356 1356 } 1357 1357 } 1358 1358 } … … 2093 2093 return new IXR_Error(404, __('Sorry, no such post.')); 2094 2094 } 2095 2095 2096 $comments = $wpdb->get_results( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");2096 $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); 2097 2097 2098 2098 if (!$comments) { 2099 2099 return array(); … … 2206 2206 } elseif (is_string($urltest['fragment'])) { 2207 2207 // ...or a string #title, a little more complicated 2208 2208 $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']); 2209 $sql = "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE '$title'";2209 $sql = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title); 2210 2210 if (! ($post_ID = $wpdb->get_var($sql)) ) { 2211 2211 // returning unknown error '0' is better than die()ing 2212 2212 return new IXR_Error(0, ''); … … 2235 2235 return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.')); 2236 2236 2237 2237 // Let's check that the remote site didn't already pingback this entry 2238 $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'");2238 $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ); 2239 2239 2240 2240 if ( $wpdb->num_rows ) // We already have a Pingback from this URL 2241 2241 return new IXR_Error(48, __('The pingback has already been registered.')); … … 2344 2344 return new IXR_Error(32, __('The specified target URL does not exist.')); 2345 2345 } 2346 2346 2347 $comments = $wpdb->get_results( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");2347 $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); 2348 2348 2349 2349 if (!$comments) { 2350 2350 return array(); -
wp-trackback.php
86 86 $comment_content = "<strong>$title</strong>\n\n$excerpt"; 87 87 $comment_type = 'trackback'; 88 88 89 $dupe = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_author_url = '$comment_author_url'");89 $dupe = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url) ); 90 90 if ( $dupe ) 91 91 trackback_response(1, 'We already have a ping from that URL for this post.'); 92 92