Changeset 3900 for trunk/wp-includes/functions.php
- Timestamp:
- 06/22/2006 07:44:36 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r3897 r3900 320 320 } 321 321 322 function weblog_ping($server = '', $path = '') {323 global $wp_version;324 include_once (ABSPATH . WPINC . '/class-IXR.php');325 326 // using a timeout of 3 seconds should be enough to cover slow servers327 $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));328 $client->timeout = 3;329 $client->useragent .= ' -- WordPress/'.$wp_version;330 331 // when set to true, this outputs debug messages by itself332 $client->debug = false;333 $home = trailingslashit( get_option('home') );334 if ( !$client->query('weblogUpdates.extendedPing', get_settings('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping335 $client->query('weblogUpdates.ping', get_settings('blogname'), $home);336 }337 338 function generic_ping($post_id = 0) {339 $services = get_settings('ping_sites');340 $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines341 $services = trim($services);342 if ( '' != $services ) {343 $services = explode("\n", $services);344 foreach ($services as $service) {345 weblog_ping($service);346 }347 }348 349 return $post_id;350 }351 352 // Send a Trackback353 function trackback($trackback_url, $title, $excerpt, $ID) {354 global $wpdb, $wp_version;355 356 if ( empty($trackback_url) )357 return;358 359 $title = urlencode($title);360 $excerpt = urlencode($excerpt);361 $blog_name = urlencode(get_settings('blogname'));362 $tb_url = $trackback_url;363 $url = urlencode(get_permalink($ID));364 $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";365 $trackback_url = parse_url($trackback_url);366 $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n";367 $http_request .= 'Host: '.$trackback_url['host']."\r\n";368 $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n";369 $http_request .= 'Content-Length: '.strlen($query_string)."\r\n";370 $http_request .= "User-Agent: WordPress/" . $wp_version;371 $http_request .= "\r\n\r\n";372 $http_request .= $query_string;373 if ( '' == $trackback_url['port'] )374 $trackback_url['port'] = 80;375 $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);376 @fputs($fs, $http_request);377 /*378 $debug_file = 'trackback.log';379 $fp = fopen($debug_file, 'a');380 fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");381 while(!@feof($fs)) {382 fwrite($fp, @fgets($fs, 4096));383 }384 fwrite($fp, "\n\n");385 fclose($fp);386 */387 @fclose($fs);388 389 $tb_url = addslashes( $tb_url );390 $wpdb->query("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'");391 return $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_url', '')) WHERE ID = '$ID'");392 }393 394 322 function make_url_footnote($content) { 395 323 preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches); … … 819 747 global $wpdb; 820 748 return $wpdb->num_queries; 821 }822 823 function privacy_ping_filter( $sites ) {824 if ( '0' != get_option('blog_public') )825 return $sites;826 else827 return '';828 749 } 829 750 … … 1069 990 } 1070 991 1071 function do_trackbacks($post_id) {1072 global $wpdb;1073 1074 $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $post_id");1075 $to_ping = get_to_ping($post_id);1076 $pinged = get_pung($post_id);1077 if ( empty($to_ping) ) {1078 $wpdb->query("UPDATE $wpdb->posts SET to_ping = '' WHERE ID = '$post_id'");1079 return;1080 }1081 1082 if (empty($post->post_excerpt))1083 $excerpt = apply_filters('the_content', $post->post_content);1084 else1085 $excerpt = apply_filters('the_excerpt', $post->post_excerpt);1086 $excerpt = str_replace(']]>', ']]>', $excerpt);1087 $excerpt = strip_tags($excerpt);1088 if ( function_exists('mb_strcut') ) // For international trackbacks1089 $excerpt = mb_strcut($excerpt, 0, 252, get_settings('blog_charset')) . '...';1090 else1091 $excerpt = substr($excerpt, 0, 252) . '...';1092 1093 $post_title = apply_filters('the_title', $post->post_title);1094 $post_title = strip_tags($post_title);1095 1096 if ($to_ping) : foreach ($to_ping as $tb_ping) :1097 $tb_ping = trim($tb_ping);1098 if ( !in_array($tb_ping, $pinged) ) {1099 trackback($tb_ping, $post_title, $excerpt, $post_id);1100 $pinged[] = $tb_ping;1101 } else {1102 $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_ping', '')) WHERE ID = '$post_id'");1103 }1104 endforeach; endif;1105 }1106 1107 function do_all_pings() {1108 global $wpdb;1109 1110 // Do pingbacks1111 while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {1112 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';");1113 pingback($ping->post_content, $ping->ID);1114 }1115 1116 // Do Enclosures1117 while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {1118 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';");1119 do_enclose($enclosure->post_content, $enclosure->ID);1120 }1121 1122 // Do Trackbacks1123 $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");1124 if ( is_array($trackbacks) ) {1125 foreach ( $trackbacks as $trackback ) {1126 do_trackbacks($trackback->ID);1127 }1128 }1129 1130 //Do Update Services/Generic Pings1131 generic_ping();1132 }1133 1134 992 function wp_proxy_check($ipnum) { 1135 993 if ( get_option('open_proxy_check') && isset($ipnum) ) {
Note: See TracChangeset
for help on using the changeset viewer.