From cc9dc67ff8387fe33862faba36af2776f4fff1c5 Mon Sep 17 00:00:00 2001 From: Donncha O Caoimh Date: Mon, 18 Oct 2004 12:09:20 +0000 Subject: [PATCH] Enclosure support moved to functions.php - it now scans the content and encloses file of mime type "video", "audio" and "image". Fixed a bug in upgrade.php - extra character at the start of file. git-svn-id: https://develop.svn.wordpress.org/trunk@1812 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/edit-form-advanced.php | 3 -- wp-admin/post.php | 43 ++--------------- wp-admin/upgrade.php | 2 +- wp-includes/functions.php | 84 +++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 42 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 9adfa54473..927aff6a3f 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -132,9 +132,6 @@ if ('publish' != $post_status || 0 == $post_ID) { ?>

- - - query(" UPDATE $wpdb->posts SET @@ -338,7 +339,7 @@ $now_gmt = current_time('mysql', 1); to_ping = '$trackback', post_modified = '$now', post_modified_gmt = '$now_gmt', - post_parent = '$post_parent' + post_parent = '$post_parent' WHERE ID = $post_ID "); // Meta Stuff @@ -372,47 +373,13 @@ $now_gmt = current_time('mysql', 1); $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_ID, $new_cat)"); } - // Enclosures - $enclosures = split( " ", $enclosure_url ); - if( is_array( $enclosures ) ) { - while( list( $key, $url ) = each( $enclosures ) ) { - if( $url != '' ) { - // READ INFO FROM REMOTE HOST - $file = str_replace( "http://", "", $url ); - $host = substr( $file, 0, strpos( $file, "/" ) ); - $file = substr( $file, strpos( $file, "/" ) ); - $headers = "HEAD $file HTTP/1.1\r\nHOST: $host\r\n\r\n"; - $port = 80; - $timeout = 3; - $fp = fsockopen($host, $port, $errno, $errstr, $timeout); - if( $fp ) { - fputs($fp, $headers ); - $response = ''; - while (!feof($fp)) - $response .= fgets($fp, 2048); - } else { - $response = ''; - } - if( $response != '' ) { - $len = substr( $response, strpos( $response, "Content-Length:" ) + 16 ); - $len = substr( $len, 0, strpos( $len, "\n" ) ); - $type = substr( $response, strpos( $response, "Content-Type:" ) + 14 ); - $type = substr( $type, 0, strpos( $type, "\n" ) + 1 ); - $meta_value = "$url\n$len\n$type\n"; - $query = "INSERT INTO `".$wpdb->postmeta."` ( `meta_id` , `post_id` , `meta_key` , `meta_value` ) - VALUES ( NULL, '$post_ID', 'enclosure' , '".$meta_value."')"; - $wpdb->query( $query ); - } - } - } - } - if ($prev_status != 'publish' && $post_status == 'publish') do_action('private_to_published', $post_ID); if ($post_status == 'publish') { do_action('publish_post', $post_ID); do_trackbacks($post_ID); + do_enclose( $content, $post_ID ); if ( get_option('default_pingback_flag') ) pingback($content, $post_ID); } diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php index db455d833d..c73fed3765 100644 --- a/wp-admin/upgrade.php +++ b/wp-admin/upgrade.php @@ -1,4 +1,4 @@ -l + + foreach($post_links_temp[0] as $link_test) : + if ( !in_array($link_test, $pung) ) : // If we haven't pung it already + $test = parse_url($link_test); + if (isset($test['query'])) + $post_links[] = $link_test; + elseif(($test['path'] != '/') && ($test['path'] != '')) + $post_links[] = $link_test; + endif; + endforeach; + + foreach ($post_links as $url){ + if( $url != '' && in_array($url, $pung) == false ) { + set_time_limit( 60 ); + $file = str_replace( "http://", "", $url ); + $host = substr( $file, 0, strpos( $file, "/" ) ); + $file = substr( $file, strpos( $file, "/" ) ); + $headers = "HEAD $file HTTP/1.1\r\nHOST: $host\r\n\r\n"; + $port = 80; + $timeout = 3; + $fp = fsockopen($host, $port, $err_num, $err_msg, $timeout); + if( $fp ) { + fputs($fp, $headers ); + $response = ''; + while (!feof($fp)) + $response .= fgets($fp, 2048); + fclose( $fp ); + } else { + $response = ''; + } + if( $response != '' ) { + $len = substr( $response, strpos( $response, "Content-Length:" ) + 16 ); + $len = substr( $len, 0, strpos( $len, "\n" ) ); + $type = substr( $response, strpos( $response, "Content-Type:" ) + 14 ); + $type = substr( $type, 0, strpos( $type, "\n" ) + 1 ); + $allowed_types = array( "video", "audio", "image" ); + if( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { + $meta_value = "$url\n$len\n$type\n"; + $query = "INSERT INTO `".$wpdb->postmeta."` ( `meta_id` , `post_id` , `meta_key` , `meta_value` ) + VALUES ( NULL, '$post_ID', 'enclosure' , '".$meta_value."')"; + $wpdb->query( $query ); + add_ping( $post_ID, $url ); + } + } + } + } +} + function pingback($content, $post_ID) { global $wp_version, $wpdb; include_once (ABSPATH . WPINC . '/class-IXR.php'); @@ -808,6 +891,7 @@ function pingback($content, $post_ID) { $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048); if ($pingback_server_url) { + set_time_limit( 60 ); // Now, the RPC call debug_fwrite($log, "Page Linked To: $pagelinkedto \n"); debug_fwrite($log, 'Page Linked From: ');