home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Blogs / wordpress2.6.exe / wordpress2.6 / wp-admin / update-links.php < prev    next >
Encoding:
PHP Script  |  2008-05-21  |  1.4 KB  |  45 lines

  1. <?php
  2. require_once('../wp-load.php');
  3. require_once( ABSPATH . 'wp-includes/class-snoopy.php');
  4.  
  5. if ( !get_option('use_linksupdate') )
  6.     wp_die(__('Feature disabled.'));
  7.  
  8. $link_uris = $wpdb->get_col("SELECT link_url FROM $wpdb->links");
  9.  
  10. if ( !$link_uris )
  11.     wp_die(__('No links'));
  12.  
  13. $link_uris = urlencode( join( $link_uris, "\n" ) );
  14.  
  15. $query_string = "uris=$link_uris";
  16.  
  17. $http_request  = "POST /updated-batch/ HTTP/1.0\r\n";
  18. $http_request .= "Host: api.pingomatic.com\r\n";
  19. $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_option('blog_charset')."\r\n";
  20. $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
  21. $http_request .= 'User-Agent: WordPress/' . $wp_version . "\r\n";
  22. $http_request .= "\r\n";
  23. $http_request .= $query_string;
  24.  
  25. $response = '';
  26. if ( false !== ( $fs = @fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) {
  27.     fwrite($fs, $http_request);
  28.     while ( !feof($fs) )
  29.         $response .= fgets($fs, 1160); // One TCP-IP packet
  30.     fclose($fs);
  31.  
  32.     $response = explode("\r\n\r\n", $response, 2);
  33.     $body = trim( $response[1] );
  34.     $body = str_replace(array("\r\n", "\r"), "\n", $body);
  35.  
  36.     $returns = explode("\n", $body);
  37.  
  38.     foreach ($returns as $return) :
  39.         $time = substr($return, 0, 19);
  40.         $uri = preg_replace('/(.*?) | (.*?)/', '$2', $return);
  41.         $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) );
  42.     endforeach;
  43. }
  44. ?>
  45.