Changeset 1812 for trunk/wp-includes/functions.php
- Timestamp:
- 10/18/2004 12:09:20 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r1802 r1812 758 758 } 759 759 760 function pingback($content, $post_ID) {760 function do_enclose( $content, $post_ID ) { 761 761 global $wp_version, $wpdb; 762 762 include_once (ABSPATH . WPINC . '/class-IXR.php'); … … 804 804 endforeach; 805 805 806 foreach ($post_links as $url){ 807 if( $url != '' && in_array($url, $pung) == false ) { 808 set_time_limit( 60 ); 809 $file = str_replace( "http://", "", $url ); 810 $host = substr( $file, 0, strpos( $file, "/" ) ); 811 $file = substr( $file, strpos( $file, "/" ) ); 812 $headers = "HEAD $file HTTP/1.1\r\nHOST: $host\r\n\r\n"; 813 $port = 80; 814 $timeout = 3; 815 $fp = fsockopen($host, $port, $err_num, $err_msg, $timeout); 816 if( $fp ) { 817 fputs($fp, $headers ); 818 $response = ''; 819 while (!feof($fp)) 820 $response .= fgets($fp, 2048); 821 fclose( $fp ); 822 } else { 823 $response = ''; 824 } 825 if( $response != '' ) { 826 $len = substr( $response, strpos( $response, "Content-Length:" ) + 16 ); 827 $len = substr( $len, 0, strpos( $len, "\n" ) ); 828 $type = substr( $response, strpos( $response, "Content-Type:" ) + 14 ); 829 $type = substr( $type, 0, strpos( $type, "\n" ) + 1 ); 830 $allowed_types = array( "video", "audio", "image" ); 831 if( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { 832 $meta_value = "$url\n$len\n$type\n"; 833 $query = "INSERT INTO `".$wpdb->postmeta."` ( `meta_id` , `post_id` , `meta_key` , `meta_value` ) 834 VALUES ( NULL, '$post_ID', 'enclosure' , '".$meta_value."')"; 835 $wpdb->query( $query ); 836 add_ping( $post_ID, $url ); 837 } 838 } 839 } 840 } 841 } 842 843 function pingback($content, $post_ID) { 844 global $wp_version, $wpdb; 845 include_once (ABSPATH . WPINC . '/class-IXR.php'); 846 847 // original code by Mort (http://mort.mine.nu:8080) 848 $log = debug_fopen(ABSPATH . '/pingback.log', 'a'); 849 $post_links = array(); 850 debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n"); 851 852 $pung = get_pung($post_ID); 853 854 // Variables 855 $ltrs = '\w'; 856 $gunk = '/#~:.?+=&%@!\-'; 857 $punc = '.:?\-'; 858 $any = $ltrs . $gunk . $punc; 859 860 // Step 1 861 // Parsing the post, external links (if any) are stored in the $post_links array 862 // This regexp comes straight from phpfreaks.com 863 // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php 864 preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp); 865 866 // Debug 867 debug_fwrite($log, 'Post contents:'); 868 debug_fwrite($log, $content."\n"); 869 870 // Step 2. 871 // Walking thru the links array 872 // first we get rid of links pointing to sites, not to specific files 873 // Example: 874 // http://dummy-weblog.org 875 // http://dummy-weblog.org/ 876 // http://dummy-weblog.org/post.php 877 // We don't wanna ping first and second types, even if they have a valid <link/> 878 879 foreach($post_links_temp[0] as $link_test) : 880 if ( !in_array($link_test, $pung) ) : // If we haven't pung it already 881 $test = parse_url($link_test); 882 if (isset($test['query'])) 883 $post_links[] = $link_test; 884 elseif(($test['path'] != '/') && ($test['path'] != '')) 885 $post_links[] = $link_test; 886 endif; 887 endforeach; 888 806 889 foreach ($post_links as $pagelinkedto){ 807 890 debug_fwrite($log, "Processing -- $pagelinkedto\n"); … … 809 892 810 893 if ($pingback_server_url) { 894 set_time_limit( 60 ); 811 895 // Now, the RPC call 812 896 debug_fwrite($log, "Page Linked To: $pagelinkedto \n");
Note: See TracChangeset
for help on using the changeset viewer.