Changeset 767

Show
Ignore:
Timestamp:
12/21/06 11:58:05 (2 years ago)
Author:
sven
Message:

RSS: add SSL feed reading support. Had to modify Snoopy a bit, and Snoopy requires curl for SSL, and I made it ignore bad certificates.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/config-dist.php

    r703 r767  
    179179// and provide the lms with the username for that user.  
    180180// This user needs write access to {$CFG->dataroot}lms/incoming/ as that is where the incoming files will end up. 
     181 
     182 
     183// For SSL feed *reading* support, Snoopy needs to know where the curl executable is. 
     184// To disable, or if curl is not available (e.g. on Windows), set to false 
     185//$CFG->curlpath = "/usr/bin/curl"; 
     186$CFG->curlpath = false; 
    181187 
    182188 
  • devel/lib/setup.php

    r742 r767  
    6464if (empty($CFG->disable_publiccomments)) { 
    6565    $CFG->disable_publiccomments = false; 
     66} 
     67 
     68if (empty($CFG->curlpath)) { 
     69    $CFG->curlpath = false; 
    6670} 
    6771 
  • devel/lib/snoopy/Snoopy.class.inc

    r269 r767  
    4343 
    4444        var $host                       =       "www.php.net";          // host name we are connecting to 
    45         var $port                       =       80;                                   // port we are connecting to 
     45        var $port                       =       "";                                   // port we are connecting to 
    4646        var $proxy_host         =       "";                                     // proxy host to use 
    4747        var $proxy_port         =       "";                                     // proxy port to use 
     
    7171         
    7272        // http accept types 
    73         var $accept                     =       "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; 
     73        var $accept                     =       ""; 
    7474         
    7575        var $results            =       "";                                     // where the content is put 
     
    117117        var $_isproxy           =       false;                          // set if using a proxy server 
    118118        var $_fp_timeout        =       30;                                     // timeout for socket connection 
     119         
     120         
     121        // CHANGE FROM UPSTREAM - added constructor 
     122        function Snoopy () { 
     123                global $CFG; 
     124                $this->curl_path = $CFG->curlpath; 
     125        } 
    119126 
    120127/*======================================================================*\ 
     
    145152                        case "http": 
    146153                                $this->host = $URI_PARTS["host"]; 
    147                                 if(!empty($URI_PARTS["port"])) 
     154                                if(!empty($URI_PARTS["port"])) { 
    148155                                        $this->port = $URI_PARTS["port"]; 
     156                                } else { // CHANGE FROM UPSTREAM 
     157                                        $this->port = 80; 
     158                                } 
    149159                                if($this->_connect($fp)) 
    150160                                { 
     
    209219                                        return false; 
    210220                                $this->host = $URI_PARTS["host"]; 
    211                                 if(!empty($URI_PARTS["port"])) 
     221                                if(!empty($URI_PARTS["port"])) { 
    212222                                        $this->port = $URI_PARTS["port"]; 
     223                                } else { // CHANGE FROM UPSTREAM 
     224                                        $this->port = 443; 
     225                                } 
    213226                                if($this->_isproxy) 
    214227                                { 
     
    10001013                        $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); 
    10011014                         
     1015                $cmdline_params = ''; 
     1016                 
    10021017                for($curr_header = 0; $curr_header < count($headers); $curr_header++) { 
    10031018                        $safer_header = strtr( $headers[$curr_header], "\"", " " ); 
     
    10111026                        $cmdline_params .= " -m ".$this->read_timeout; 
    10121027                 
    1013                 $headerfile = tempnam($temp_dir, "sno"); 
     1028                $headerfile = tempnam($this->temp_dir, "sno"); 
     1029                 
     1030                $cmdline_params .= ' -k '; // CHANGE FROM UPSTREAM - ignore bad SSL certs 
    10141031 
    10151032                $safer_URI = strtr( $URI, "\"", " " ); // strip quotes from the URI to avoid shell access 
     
    10531070                        } 
    10541071                 
    1055                         if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) 
     1072                        if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) { 
     1073                if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$result_headers[$currentHeader], $status)) // CHANGE FROM UPSTREAM 
     1074                                { 
     1075                                        $this->status= $status[1]; 
     1076                }                                
    10561077                                $this->response_code = $result_headers[$currentHeader]; 
     1078                        } 
    10571079 
    10581080                        $this->headers[] = $result_headers[$currentHeader]; 
  • devel/units/magpie/function_actions.php

    r667 r767  
    7474            $url = trim(optional_param('url')); 
    7575            if (!empty($url)) { 
    76                 if (substr($url,0,7) != "http://") { 
     76                if (!preg_match('#https?://#', $url)) { 
    7777                    $url = "http://" . $url; 
    7878                } 
     
    9393                    require_once($CFG->dirroot . 'lib/snoopy/Snoopy.class.inc'); 
    9494                    $client = new Snoopy(); 
    95                     if (@$client->fetch($url) && $client->error == '') { 
     95                    if (empty($CFG->curlpath) && substr($url,0,8) == "https://") { 
     96                        $messages[] = __gettext("Feed subscription failed: SSL feed reading is not enabled."); 
     97                    } else if (@$client->fetch($url) && $client->error == '') { 
    9698                        if (substr_count($client->results,"<channel") > 0 || substr_count($client->results,"<feed") > 0) { 
    9799                            $feed = new StdClass; 
  • devel/units/magpie/function_init.php

    r632 r767  
    1313define('rss','true'); 
    1414define('MAGPIE_DIR', $CFG->dirroot . "units/magpie/"); 
    15 define('MAGPIE_OUTPUT_ENCODING', 'utf8'); 
     15define('MAGPIE_OUTPUT_ENCODING', 'UTF-8'); 
    1616define('MAGPIE_USER_AGENT', "Elgg's furrepticiouf feed fetcher"); 
    1717require_once(MAGPIE_DIR . 'rss_fetch.inc');