Changeset 608776
- Timestamp:
- 10/06/2012 01:53:45 AM (13 years ago)
- File:
-
- 1 edited
-
globalfeed/trunk/feeds/mbgf_rss/mbgf_rss.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
globalfeed/trunk/feeds/mbgf_rss/mbgf_rss.php
r593074 r608776 538 538 'post_date' => $post_date->format('U') + $time_offset, 539 539 'post_format' => 'standard', 540 'guid' => (string) trim($update->link), 540 541 // Always prefer a GUID over the post link 542 'guid' => (isset($update->guid) ? (string) trim($update->guid) : '') . (isset($update->link) ? (string) trim($update->link) : '') , 541 543 'categories' => array(), 542 544 'tags' => array(), … … 546 548 ), 547 549 ); 550 551 // Check that a guid is not empty 552 $post_args['guid'] = str_replace(" ", "_", substr($post_args['meta']['source'], 0, 50) . $post_args['title'] . $post_args['post_date']); 553 548 554 549 555 // Process the post date … … 645 651 } 646 652 647 648 649 /**650 * Makes an HTTP request. This method can be overriden by subclasses if651 * developers want to do fancier things or use something other than curl to652 * make the request.653 *654 * @param String $url the URL to make the request to655 * @param Array $params the parameters to use for the POST body656 * @param CurlHandler $ch optional initialized curl handle657 * @return String the response text658 */659 660 protected function makeRequest($url, $params, $ch=null) {661 $globalfeed = &$this->globalfeed;662 if (!$ch) {663 $ch = curl_init();664 }665 $globalfeed->print_debug_info($params, 'mbgf_rss');666 $opts = array(667 CURLOPT_CONNECTTIMEOUT => 10,668 CURLOPT_RETURNTRANSFER => true,669 CURLOPT_TIMEOUT => 60,670 CURLOPT_USERAGENT => 'rss-php-3.0',671 );672 //if ($this->useFileUploadSupport()) {673 $opts[CURLOPT_POSTFIELDS] = $params;674 //} else {675 $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');676 // }677 $opts[CURLOPT_URL] = $url;678 679 // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait680 // for 2 seconds if the server does not support this header.681 if (isset($opts[CURLOPT_HTTPHEADER])) {682 $existing_headers = $opts[CURLOPT_HTTPHEADER];683 $existing_headers[] = 'Expect:';684 $opts[CURLOPT_HTTPHEADER] = $existing_headers;685 } else {686 $opts[CURLOPT_HTTPHEADER] = array('Expect:');687 }688 689 curl_setopt_array($ch, $opts);690 $result = curl_exec($ch);691 692 if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT693 $globalfeed->print_error_info('Invalid or no certificate authority found, '.694 'using bundled information');695 curl_setopt($ch, CURLOPT_CAINFO,696 dirname(__FILE__) . '/rss_ca_chain_bundle.crt');697 $result = curl_exec($ch);698 }699 $globalfeed->print_debug_info(curl_errno($ch));700 curl_close($ch);701 return $result;702 }703 704 653 705 654 /** … … 741 690 } 742 691 743 /** 744 * This function take the rawdata returned by the feed source (ie Titter, RSS etc...) and converts it into 745 * the array format expected by $this->globalfeed->save_feed_items(), then it saves it using this function. 746 * 747 * @uses $this->globalfeed->save_feed_items() 748 * @param array $feed_items An array containing the raw data from the feed source that should be parsed and saved. 749 */ 750 function store_feed_items( $feed_items ){ 751 $this->globalfeed->print_debug_info( "Store RSS Feed Items: \n" . var_export($feed_items, true) ); 752 } 753 692 754 693 function print_admin_page(){ 755 694 $mb_globalfeed = $this->globalfeed; … … 775 714 $this->register_feed (true); 776 715 } 777 778 function launchBackgroundProcess($call) {779 // Windows780 if(is_windows()){781 pclose(popen('start /b '.$call.'', 'r'));782 }783 784 // Some sort of UNIX785 else {786 pclose(popen($call.' /dev/null &', 'r'));787 }788 return true;789 }790 791 /**792 *793 * @param string $url The url of the file to be called asynchronously.794 * @param mixed|array $params An array of parameters to be posted to the script.795 * @param string $type The type of request to be sent. (POST/GET)796 */797 private function curl_request_async($url, $params, $type='GET') {798 $parts=parse_url($url);799 800 $fp = fsockopen($parts['host'],801 isset($parts['port'])?$parts['port']:80,802 $errno, $errstr, 30);803 804 805 $out = "POST ".$parts['path']." HTTP/1.1\r\n";806 $out.= "Host: ".$parts['host']."\r\n";807 $out.= "Content-Type: application/x-www-form-urlencoded\r\n";808 $out.= "Content-Length: ".strlen($post_string)."\r\n";809 $out.= "Connection: Close\r\n\r\n";810 if (isset($post_string)) $out.= $post_string;811 812 fwrite($fp, $out);813 fclose($fp);814 }815 716 816 717 }
Note: See TracChangeset
for help on using the changeset viewer.