WordPress.org

Make WordPress Core

Changeset 2495


Ignore:
Timestamp:
03/29/2005 04:58:30 PM (15 years ago)
Author:
ryan
Message:

Check for failed socket open in update-links. http://mosquito.wordpress.org/view.php?id=1025 Props: ColdForged

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/update-links.php

    r2313 r2495  
    2424
    2525$response = '';
    26 $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 = addslashes( substr($return, 0, 19) );
    40     $uri = addslashes( preg_replace('/(.*?) | (.*?)/', '$2', $return) );
    41     $wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'");
    42 endforeach;
    43 
     26if( 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 = addslashes( substr($return, 0, 19) );
     40        $uri = addslashes( preg_replace('/(.*?) | (.*?)/', '$2', $return) );
     41        $wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'");
     42    endforeach;
     43}
    4444?>
Note: See TracChangeset for help on using the changeset viewer.