Use CURL if available, possible fix for http://mosquito.wordpress.org/view.php?id=1166

git-svn-id: http://svn.automattic.com/wordpress/trunk@2581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2005-05-03 07:52:11 +00:00
parent 2fd04bb902
commit 95883b9211
3 changed files with 26 additions and 11 deletions

View File

@ -215,6 +215,8 @@ function populate_options() {
add_option('open_proxy_check', 1); add_option('open_proxy_check', 1);
add_option('rss_language', 'en'); add_option('rss_language', 'en');
add_option('html_type', 'text/html'); add_option('html_type', 'text/html');
// 1.5.1
add_option('use_trackback', 0);
// Delete unused options // Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url'); $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url');

View File

@ -1858,4 +1858,24 @@ function add_magic_quotes($array) {
return $array; return $array;
} }
?> function wp_remote_fopen( $uri ) {
if ( function_exists('curl_init') ) {
$handle = curl_init();
curl_setopt ($handle, CURLOPT_URL, $uri);
curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($handle);
curl_close($handle);
return $buffer;
} else {
$fp = fopen( $uri, 'r' );
if ( !$fp )
return false;
$linea = '';
while( $remote_read = fread($fp, 4096) )
$linea .= $remote_read;
return $linea;
}
}
?>

View File

@ -1162,16 +1162,9 @@ class wp_xmlrpc_server extends IXR_Server {
sleep(1); sleep(1);
// Let's check the remote site // Let's check the remote site
$fp = @fopen($pagelinkedfrom, 'r'); $linea = wp_remote_fopen( $pagelinkedfrom );
if (!$fp) { if ( !$linea )
// The source URI does not exist
return new IXR_Error(16, 'The source URI does not exist.'); return new IXR_Error(16, 'The source URI does not exist.');
}
$puntero = 4096;
while($remote_read = fread($fp, $puntero)) {
$linea .= $remote_read;
}
// Work around bug in strip_tags(): // Work around bug in strip_tags():
$linea = str_replace('<!DOCTYPE','<DOCTYPE',$linea); $linea = str_replace('<!DOCTYPE','<DOCTYPE',$linea);
@ -1179,7 +1172,7 @@ class wp_xmlrpc_server extends IXR_Server {
$linea = strip_all_but_one_link($linea, $pagelinkedto); $linea = strip_all_but_one_link($linea, $pagelinkedto);
// I don't think we need this? -- emc3 // I don't think we need this? -- emc3
//$linea = preg_replace('#&([^amp\;])#is', '&amp;$1', $linea); //$linea = preg_replace('#&([^amp\;])#is', '&amp;$1', $linea);
if (empty($matchtitle)) { if ( empty($matchtitle) ) {
preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle); preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
} }
$pos2 = strpos($linea, $pagelinkedto); $pos2 = strpos($linea, $pagelinkedto);