Move the link timestamp updater to the new HTTP api. See #7793 props jacobsantos.
git-svn-id: http://svn.automattic.com/wordpress/trunk@9011 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
76a37eb1ea
commit
72a97b5f8a
|
@ -15,9 +15,6 @@
|
||||||
/** Load WordPress Bootstrap */
|
/** Load WordPress Bootstrap */
|
||||||
require_once('../wp-load.php');
|
require_once('../wp-load.php');
|
||||||
|
|
||||||
/** Load Snoopy HTTP Client class */
|
|
||||||
require_once( ABSPATH . 'wp-includes/class-snoopy.php');
|
|
||||||
|
|
||||||
if ( !get_option('use_linksupdate') )
|
if ( !get_option('use_linksupdate') )
|
||||||
wp_die(__('Feature disabled.'));
|
wp_die(__('Feature disabled.'));
|
||||||
|
|
||||||
|
@ -30,31 +27,27 @@ $link_uris = urlencode( join( $link_uris, "\n" ) );
|
||||||
|
|
||||||
$query_string = "uris=$link_uris";
|
$query_string = "uris=$link_uris";
|
||||||
|
|
||||||
$http_request = "POST /updated-batch/ HTTP/1.0\r\n";
|
$options = array();
|
||||||
$http_request .= "Host: api.pingomatic.com\r\n";
|
$options['timeout'] = 30;
|
||||||
$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_option('blog_charset')."\r\n";
|
$options['body'] = $query_string;
|
||||||
$http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
|
|
||||||
$http_request .= 'User-Agent: WordPress/' . $wp_version . "\r\n";
|
|
||||||
$http_request .= "\r\n";
|
|
||||||
$http_request .= $query_string;
|
|
||||||
|
|
||||||
$response = '';
|
$options['headers'] = array(
|
||||||
if ( false !== ( $fs = @fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) {
|
'content-type' => 'application/x-www-form-urlencoded; charset='.get_option('blog_charset'),
|
||||||
fwrite($fs, $http_request);
|
'content-length' => strlen( $query_string ),
|
||||||
while ( !feof($fs) )
|
);
|
||||||
$response .= fgets($fs, 1160); // One TCP-IP packet
|
|
||||||
fclose($fs);
|
|
||||||
|
|
||||||
$response = explode("\r\n\r\n", $response, 2);
|
$response = wp_remote_get('http://api.pingomatic.com/updated-batch/', $options);
|
||||||
$body = trim( $response[1] );
|
|
||||||
$body = str_replace(array("\r\n", "\r"), "\n", $body);
|
|
||||||
|
|
||||||
$returns = explode("\n", $body);
|
if ( $response['response']['code'] != 200 )
|
||||||
|
wp_die(__('Request Failed.'));
|
||||||
|
|
||||||
|
$body = str_replace(array("\r\n", "\r"), "\n", $response['body']);
|
||||||
|
$returns = explode("\n", $body);
|
||||||
|
|
||||||
|
foreach ($returns as $return) :
|
||||||
|
$time = substr($return, 0, 19);
|
||||||
|
$uri = preg_replace('/(.*?) | (.*?)/', '$2', $return);
|
||||||
|
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) );
|
||||||
|
endforeach;
|
||||||
|
|
||||||
foreach ($returns as $return) :
|
|
||||||
$time = substr($return, 0, 19);
|
|
||||||
$uri = preg_replace('/(.*?) | (.*?)/', '$2', $return);
|
|
||||||
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) );
|
|
||||||
endforeach;
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue