mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Send blog links to pingomatic.com to update.
mp-wp_genesis 4 *
mp-wp_genesis 5 * You can disable this feature by deleting the option 'use_linksupdate' or
mp-wp_genesis 6 * setting the option to false. If no links exist, then no links are sent.
mp-wp_genesis 7 *
mp-wp_genesis 8 * Snoopy is included, but is not used. Fsockopen() is used instead to send link
mp-wp_genesis 9 * URLs.
mp-wp_genesis 10 *
mp-wp_genesis 11 * @package WordPress
mp-wp_genesis 12 * @subpackage Administration
mp-wp_genesis 13 */
mp-wp_genesis 14
mp-wp_genesis 15 /** Load WordPress Bootstrap */
mp-wp_genesis 16 require_once('../wp-load.php');
mp-wp_genesis 17
mp-wp_genesis 18 if ( !get_option('use_linksupdate') )
mp-wp_genesis 19 wp_die(__('Feature disabled.'));
mp-wp_genesis 20
mp-wp_genesis 21 $link_uris = $wpdb->get_col("SELECT link_url FROM $wpdb->links");
mp-wp_genesis 22
mp-wp_genesis 23 if ( !$link_uris )
mp-wp_genesis 24 wp_die(__('No links'));
mp-wp_genesis 25
mp-wp_genesis 26 $link_uris = urlencode( join( $link_uris, "\n" ) );
mp-wp_genesis 27
mp-wp_genesis 28 $query_string = "uris=$link_uris";
mp-wp_genesis 29
mp-wp_genesis 30 $options = array();
mp-wp_genesis 31 $options['timeout'] = 30;
mp-wp_genesis 32 $options['body'] = $query_string;
mp-wp_genesis 33
mp-wp_genesis 34 $options['headers'] = array(
mp-wp_genesis 35 'content-type' => 'application/x-www-form-urlencoded; charset='.get_option('blog_charset'),
mp-wp_genesis 36 'content-length' => strlen( $query_string ),
mp-wp_genesis 37 );
mp-wp_genesis 38
mp-wp_genesis 39 $response = wp_remote_get('http://api.pingomatic.com/updated-batch/', $options);
mp-wp_genesis 40
mp-wp_genesis 41 if ( is_wp_error( $response ) )
mp-wp_genesis 42 wp_die(__('Request Failed.'));
mp-wp_genesis 43
mp-wp_genesis 44 if ( $response['response']['code'] != 200 )
mp-wp_genesis 45 wp_die(__('Request Failed.'));
mp-wp_genesis 46
mp-wp_genesis 47 $body = str_replace(array("\r\n", "\r"), "\n", $response['body']);
mp-wp_genesis 48 $returns = explode("\n", $body);
mp-wp_genesis 49
mp-wp_genesis 50 foreach ($returns as $return) :
mp-wp_genesis 51 $time = substr($return, 0, 19);
mp-wp_genesis 52 $uri = preg_replace('/(.*?) | (.*?)/', '$2', $return);
mp-wp_genesis 53 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) );
mp-wp_genesis 54 endforeach;
mp-wp_genesis 55
mp-wp_genesis 56 ?>