Move the link timestamp updater to the new HTTP api. See #7793 props jacobsantos.

git-svn-id: https://develop.svn.wordpress.org/trunk@9011 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood 2008-09-27 21:39:22 +00:00
parent 745e36be78
commit 1c0cbe3cbf
1 changed files with 19 additions and 26 deletions

View File

@ -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;
}
?> ?>