summaryrefslogtreecommitdiffstats
path: root/wp-admin/update-links.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-22 18:31:50 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-22 18:31:50 +0000
commitd48e85e0ac5e675ca33fac173f30c75403d1033f (patch)
tree1164430fa3b83a4d9283961b09c1576f2885e6b2 /wp-admin/update-links.php
parent086dcde66603301531efc6d8087bd06d0546f148 (diff)
downloadwordpress-mu-d48e85e0ac5e675ca33fac173f30c75403d1033f.tar.gz
wordpress-mu-d48e85e0ac5e675ca33fac173f30c75403d1033f.tar.xz
wordpress-mu-d48e85e0ac5e675ca33fac173f30c75403d1033f.zip
Moved everything in wp-inst down a directory.
Uses's Ryan Boren's htaccess rules and mods If you're upgrading, try this on a test server first! git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@591 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/update-links.php')
-rw-r--r--wp-admin/update-links.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/wp-admin/update-links.php b/wp-admin/update-links.php
new file mode 100644
index 0000000..46a7f5a
--- /dev/null
+++ b/wp-admin/update-links.php
@@ -0,0 +1,44 @@
+<?php
+require_once( dirname( dirname(__FILE__) ) . '/wp-config.php');
+require_once( ABSPATH . 'wp-includes/class-snoopy.php');
+
+if ( !get_option('use_linksupdate') )
+ die(__('Feature disabled.'));
+
+$link_uris = $wpdb->get_col("SELECT link_url FROM $wpdb->links");
+
+if ( !$link_uris )
+ die('No links');
+
+$link_uris = urlencode( join( $link_uris, "\n" ) );
+
+$query_string = "uris=$link_uris";
+
+$http_request = "POST /updated-batch/ HTTP/1.0\r\n";
+$http_request .= "Host: api.pingomatic.com\r\n";
+$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n";
+$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 = '';
+if( false !== ( $fs = fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) {
+ fwrite($fs, $http_request);
+ while ( !feof($fs) )
+ $response .= fgets($fs, 1160); // One TCP-IP packet
+ fclose($fs);
+
+ $response = explode("\r\n\r\n", $response, 2);
+ $body = trim( $response[1] );
+ $body = str_replace(array("\r\n", "\r"), "\n", $body);
+
+ $returns = explode("\n", $body);
+
+ foreach ($returns as $return) :
+ $time = $wpdb->escape( substr($return, 0, 19) );
+ $uri = $wpdb->escape( preg_replace('/(.*?) | (.*?)/', '$2', $return) );
+ $wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'");
+ endforeach;
+}
+?>