Ticket #5065: wp-user-agent.patch
File wp-user-agent.patch, 6.1 KB (added by , 17 years ago) |
---|
-
wp-admin/includes/update.php
82 82 $http_request .= "Host: api.wordpress.org\r\n"; 83 83 $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n"; 84 84 $http_request .= "Content-Length: " . strlen($request) . "\r\n"; 85 $http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n";85 $http_request .= 'User-Agent: ' . wp_user_agent( Array( '(' . get_bloginfo('url') . ')' ) ) . "\r\n"; 86 86 $http_request .= "\r\n"; 87 87 $http_request .= $request; 88 88 -
wp-admin/update-links.php
18 18 $http_request .= "Host: api.pingomatic.com\r\n"; 19 19 $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_option('blog_charset')."\r\n"; 20 20 $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n"; 21 $http_request .= 'User-Agent: WordPress/' . $wp_version. "\r\n";21 $http_request .= 'User-Agent: ' . wp_user_agent() . "\r\n"; 22 22 $http_request .= "\r\n"; 23 23 $http_request .= $query_string; 24 24 -
wp-includes/comment.php
552 552 return false; 553 553 554 554 // Send the GET request 555 $request = "GET $path HTTP/1.1\r\nHost: $host\r\nUser-Agent: WordPress/$wp_version\r\n\r\n";555 $request = "GET $path HTTP/1.1\r\nHost: $host\r\nUser-Agent: " . wp_user_agent() . "\r\n\r\n"; 556 556 // ob_end_flush(); 557 557 fputs($fp, $request); 558 558 … … 778 778 $http_request .= 'Host: '.$trackback_url['host']."\r\n"; 779 779 $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_option('blog_charset')."\r\n"; 780 780 $http_request .= 'Content-Length: '.strlen($query_string)."\r\n"; 781 $http_request .= "User-Agent: WordPress/" . $wp_version;781 $http_request .= "User-Agent: " . wp_user_agent(); 782 782 $http_request .= "\r\n\r\n"; 783 783 $http_request .= $query_string; 784 784 if ( '' == $trackback_url['port'] ) -
wp-includes/functions.php
529 529 endforeach; 530 530 } 531 531 532 /** 533 * This function generates a User-Agent string suitable for making HTTP 534 * requests with. 535 * @param {Array} $extra A hash with extra key/versions to include. 536 * @returns {String} 537 */ 538 function wp_user_agent( $extra='' ){ 539 /* Notes: 540 * User-Agents are defined in RFC 1945 and RFC 2068. 541 * Approximately, they may only consist of alpha-numerics and 542 * periods and underlines. Parenthesis enclose comments. 543 */ 544 global $wp_version; 545 $parts = Array("WordPress/" . $wp_version); 546 if ( !empty($extra) ) { 547 foreach ( $extra as $key => $version ) { 548 if ( is_integer($key) ) { 549 /* No key part was provided, the Array is incrementing. */ 550 array_push( $parts, $version ); 551 } elseif ( empty($version) ) { 552 array_push( $parts, $key ); 553 } else { 554 array_push( $parts, $key . '/' . $version ); 555 } 556 } 557 } 558 return apply_filters('wp_user_agent', implode( ' ', $parts )); 559 } 560 532 561 function wp_get_http_headers( $url, $red = 1 ) { 533 562 global $wp_version; 534 563 @set_time_limit( 60 ); … … 542 571 if ( !isset( $parts['port'] ) ) 543 572 $parts['port'] = 80; 544 573 545 $head = "HEAD $file HTTP/1.1\r\nHOST: $host\r\nUser-Agent: WordPress/" . $wp_version. "\r\n\r\n";574 $head = "HEAD $file HTTP/1.1\r\nHOST: $host\r\nUser-Agent: " . wp_user_agent() . "\r\n\r\n"; 546 575 547 576 $fp = @fsockopen($host, $parts['port'], $err_num, $err_msg, 3); 548 577 if ( !$fp ) -
wp-includes/rss.php
11 11 12 12 define('RSS', 'RSS'); 13 13 define('ATOM', 'Atom'); 14 define('MAGPIE_USER_AGENT', 'WordPress/' . $GLOBALS['wp_version']);14 define('MAGPIE_USER_AGENT', wp_user_agent()); 15 15 16 16 class MagpieRSS { 17 17 var $parser; … … 595 595 } 596 596 597 597 if ( !defined('MAGPIE_USER_AGENT') ) { 598 $ua = 'WordPress/' . $GLOBALS['wp_version'];598 $ua = wp_user_agent(); 599 599 600 600 if ( MAGPIE_CACHE_ON ) { 601 601 $ua = $ua . ')'; … … 866 866 } 867 867 endif; 868 868 869 ?> 870 No newline at end of file 869 ?> -
wp-includes/update.php
26 26 $http_request = "GET /core/version-check/1.0/?version=$wp_version&php=$php_version&locale=$locale HTTP/1.0\r\n"; 27 27 $http_request .= "Host: api.wordpress.org\r\n"; 28 28 $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n"; 29 $http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n";29 $http_request .= 'User-Agent: ' . wp_user_agent( Array( '(' . get_bloginfo('url') . ')' ) ) . "\r\n"; 30 30 $http_request .= "\r\n"; 31 31 32 32 $response = ''; … … 51 51 52 52 add_action( 'init', 'wp_version_check' ); 53 53 54 ?> 55 No newline at end of file 54 ?> -
wp-content/plugins/akismet/akismet.php
165 165 $http_request .= "Host: $host\r\n"; 166 166 $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n"; 167 167 $http_request .= "Content-Length: " . strlen($request) . "\r\n"; 168 $http_request .= "User-Agent: WordPress/$wp_version | Akismet/2.0\r\n";168 $http_request .= "User-Agent: " . wp_user_agent( Array( 'Akismet' => '2.0') ) . "\r\n"; 169 169 $http_request .= "\r\n"; 170 170 $http_request .= $request; 171 171