From eda8b55ac0256b369c08070c9d2ef34d3cbbe4b7 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Mon, 14 Feb 2005 03:11:23 +0000 Subject: [PATCH] Removal of changes.xml bloat. git-svn-id: http://svn.automattic.com/wordpress/trunk@2313 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/options-misc.php | 33 +----- wp-admin/update-links.php | 44 ++++++++ wp-content/links-update-cache.xml | 0 wp-includes/links-update-xml.php | 174 ------------------------------ 4 files changed, 46 insertions(+), 205 deletions(-) create mode 100644 wp-admin/update-links.php delete mode 100755 wp-content/links-update-cache.xml delete mode 100644 wp-includes/links-update-xml.php diff --git a/wp-admin/options-misc.php b/wp-admin/options-misc.php index 212665cc6..7ffd0f57a 100644 --- a/wp-admin/options-misc.php +++ b/wp-admin/options-misc.php @@ -58,37 +58,8 @@ include('admin-header.php'); -
- - /> - - - - - - - - - - - - - - - - - - -
-
- http://static.wordpress.org/changes.xml') ?> - -
- -
-

' ) ?>

-
- +

/> +

diff --git a/wp-admin/update-links.php b/wp-admin/update-links.php new file mode 100644 index 000000000..53787de37 --- /dev/null +++ b/wp-admin/update-links.php @@ -0,0 +1,44 @@ +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 = ''; +$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 = addslashes( substr($return, 0, 19) ); + $uri = addslashes( preg_replace('/(.*?) | (.*?)/', '$2', $return) ); + $wpdb->query("UPDATE $wpdb->links SET link_updated = '$time' WHERE link_url = '$uri'"); +endforeach; + +?> \ No newline at end of file diff --git a/wp-content/links-update-cache.xml b/wp-content/links-update-cache.xml deleted file mode 100755 index e69de29bb..000000000 diff --git a/wp-includes/links-update-xml.php b/wp-includes/links-update-xml.php deleted file mode 100644 index 7c9e8ef97..000000000 --- a/wp-includes/links-update-xml.php +++ /dev/null @@ -1,174 +0,0 @@ -get_results("SELECT link_id, link_url FROM $wpdb->links WHERE link_visible = 'Y' AND link_url <> ''"); - foreach ($links as $link) { - $link_url = transform_url($link->link_url); - $all_links[$link_url] = array($link->link_id, 0); - } -} - -/** - ** update_links() - ** Update in the db the links which have been updated ($all_links[url][1] != 0) - **/ -function update_links() { - global $all_links, $wpdb; - reset($all_links); - while (list($id, $val) = each($all_links)) { - if ($val[1]) { - $wpdb->query("UPDATE $wpdb->links SET link_updated = '$val[1]' WHERE link_id = $val[0]"); - } - } // end while -} - -/** - ** get_weblogs_updatedfile() - ** Retrieves and caches a copy of the weblogs.com changed blogs xml file. - ** If the file exists check it's age, get new copy if old. - ** If a new or updated file has been written return true (needs processing) - ** otherwise return false (nothing to do) - **/ -function get_weblogs_updatedfile() { - global $ignore_weblogs_cache; - $update = false; - $file = ABSPATH . 'wp-content/links-update-cache.xml'; - if ($ignore_weblogs_cache) { - $update = true; - } else { - if (file_exists($file)) { - // is it old? - $modtime = filemtime($file); - if ((time() - $modtime) > (1.5 * 60)) { - $update = true; - } - } else { // doesn't exist - $update = true; - } - } - - if ($update) { - // get a new copy - $a = @file(get_settings('weblogs_xml_url')); - if ($a != false && count($a) && $a[0]) { - $contents = implode('', $a); - - // Clean up the input, because weblogs.com doesn't output clean XML - $contents = preg_replace("/'/",''',$contents); - $contents = preg_replace('|[^[:space:][:punct:][:alpha:][:digit:]]|','',$contents); - - $cachefp = fopen(ABSPATH . 'wp-content/links-update-cache.xml', "w"); - fwrite($cachefp, $contents); - fclose($cachefp); - } else { - return false; //don't try to process - } - } - return $update; -} - -/** - ** startElement() - ** Callback function. Called at the start of a new xml tag. - **/ -function startElement($parser, $tagName, $attrs) { - global $updated_timestamp, $all_links; - if ($tagName == 'WEBLOGUPDATES') { - //convert 'updated' into php date variable - $updated_timestamp = strtotime($attrs['UPDATED']); - //echo('got timestamp of ' . gmdate('F j, Y, H:i:s', $updated_timestamp) . "\n"); - } else if ($tagName == 'WEBLOG') { - // is this url in our links? - $link_url = transform_url($attrs['URL']); - if (isset($all_links[$link_url])) { - $all_links[$link_url][1] = date('YmdHis', $updated_timestamp - $attrs['WHEN']); - //echo('set link id ' . $all_links[$link_url][0] . ' to date ' . $all_links[$link_url][1] . "\n"); - } - } -} - -/** - ** endElement() - ** Callback function. Called at the end of an xml tag. - **/ -function endElement($parser, $tagName) { - // nothing to do. -} - -/** - ** transform_url() - ** Transforms a url to a minimal identifier. - ** - ** Remove www, remove index.* or default.*, remove - ** trailing slash - **/ -function transform_url($url) { - //echo("transform_url(): $url "); - $url = str_replace('www.', '', $url); - $url = str_replace('WWW.', '', $url); - $url = preg_replace('/(?:index|default)\.[a-z]{2,}/i', '', $url); - if (substr($url, -1, 1) == '/') { - $url = substr($url, 0, -1); - } - //echo(" now equals $url\n"); - return $url; -} // end transform_url - -// get/update the cache file. -// true return means new copy -if (get_weblogs_updatedfile()) { - //echo('
');
-	// pre-load the links
-	preload_links();
-
-	// Create an XML parser
-	$xml_parser = xml_parser_create();
-
-	// Set the functions to handle opening and closing tags
-	xml_set_element_handler($xml_parser, "startElement", "endElement");
-
-	// Open the XML file for reading
-	$fp = fopen(ABSPATH . 'wp-content/links-update-cache.xml', "r")
-		  or die("Error reading XML data.");
-
-	// Read the XML file 16KB at a time
-	while ($data = fread($fp, 16384)) {
-		// Parse each 4KB chunk with the XML parser created above
-		xml_parse($xml_parser, $data, feof($fp))
-				or die(sprintf("XML error: %s at line %d",
-					xml_error_string(xml_get_error_code($xml_parser)),
-					xml_get_current_line_number($xml_parser)));
-	}
-
-	// Close the XML file
-	fclose($fp);
-
-	// Free up memory used by the XML parser
-	xml_parser_free($xml_parser);
-
-	// now update the db with latest times
-	update_links();
-
-	//echo('
'); -} // end if updated cache file - -?> \ No newline at end of file