Changeset 9011 for trunk/wp-admin/update-links.php
- Timestamp:
- 09/27/2008 09:39:22 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/update-links.php
r8645 r9011 16 16 require_once('../wp-load.php'); 17 17 18 /** Load Snoopy HTTP Client class */19 require_once( ABSPATH . 'wp-includes/class-snoopy.php');20 21 18 if ( !get_option('use_linksupdate') ) 22 19 wp_die(__('Feature disabled.')); … … 31 28 $query_string = "uris=$link_uris"; 32 29 33 $http_request = "POST /updated-batch/ HTTP/1.0\r\n"; 34 $http_request .= "Host: api.pingomatic.com\r\n"; 35 $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_option('blog_charset')."\r\n"; 36 $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n"; 37 $http_request .= 'User-Agent: WordPress/' . $wp_version . "\r\n"; 38 $http_request .= "\r\n"; 39 $http_request .= $query_string; 30 $options = array(); 31 $options['timeout'] = 30; 32 $options['body'] = $query_string; 40 33 41 $response = ''; 42 if ( false !== ( $fs = @fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) { 43 fwrite($fs, $http_request); 44 while ( !feof($fs) ) 45 $response .= fgets($fs, 1160); // One TCP-IP packet 46 fclose($fs); 34 $options['headers'] = array( 35 'content-type' => 'application/x-www-form-urlencoded; charset='.get_option('blog_charset'), 36 'content-length' => strlen( $query_string ), 37 ); 47 38 48 $response = explode("\r\n\r\n", $response, 2); 49 $body = trim( $response[1] ); 50 $body = str_replace(array("\r\n", "\r"), "\n", $body); 39 $response = wp_remote_get('http://api.pingomatic.com/updated-batch/', $options); 51 40 52 $returns = explode("\n", $body); 41 if ( $response['response']['code'] != 200 ) 42 wp_die(__('Request Failed.')); 53 43 54 foreach ($returns as $return) : 55 $time = substr($return, 0, 19); 56 $uri = preg_replace('/(.*?) | (.*?)/', '$2', $return); 57 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) ); 58 endforeach; 59 } 44 $body = str_replace(array("\r\n", "\r"), "\n", $response['body']); 45 $returns = explode("\n", $body); 46 47 foreach ($returns as $return) : 48 $time = substr($return, 0, 19); 49 $uri = preg_replace('/(.*?) | (.*?)/', '$2', $return); 50 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) ); 51 endforeach; 52 60 53 ?>
Note: See TracChangeset
for help on using the changeset viewer.