]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17617 removed some uses of snoopy library
authorskodak <skodak>
Thu, 8 Jan 2009 15:01:19 +0000 (15:01 +0000)
committerskodak <skodak>
Thu, 8 Jan 2009 15:01:19 +0000 (15:01 +0000)
lib/filelib.php
mod/resource/lib.php

index 3b7fbd7331372c1376b626baca6e506878963cc3..b2e9019d3cc69b59bf0bb4a53eef943c77017551 100644 (file)
@@ -344,68 +344,6 @@ function download_file_content($url, $headers=null, $postdata=null, $fullrespons
     // check if proxy (if used) should be bypassed for this url
     $proxybypass = is_proxybypass( $url );
 
-    if (!extension_loaded('curl') or ($ch = curl_init($url)) === false) {
-        require_once($CFG->libdir.'/snoopy/Snoopy.class.inc');
-        $snoopy = new Snoopy();
-        $snoopy->read_timeout = $timeout;
-        $snoopy->_fp_timeout  = $connecttimeout;
-        if (!$proxybypass) {
-            $snoopy->proxy_host   = $CFG->proxyhost;
-            $snoopy->proxy_port   = $CFG->proxyport;
-            if (!empty($CFG->proxyuser) and !empty($CFG->proxypassword)) {
-                // this will probably fail, but let's try it anyway
-                $snoopy->proxy_user     = $CFG->proxyuser;
-                $snoopy->proxy_password = $CFG->proxypassword;
-            }
-        }
-
-        if (is_array($headers) ) {
-            $client->rawheaders = $headers;
-        }
-
-        if (is_array($postdata)) {
-            $fetch = @$snoopy->fetch($url, $postdata); // use more specific debug code bellow
-        } else {
-            $fetch = @$snoopy->fetch($url); // use more specific debug code bellow
-        }
-
-        if ($fetch) {
-            if ($fullresponse) {
-                //fix header line endings
-                foreach ($snoopy->headers as $key=>$unused) {
-                    $snoopy->headers[$key] = trim($snoopy->headers[$key]);
-                }
-                $response = new object();
-                $response->status        = $snoopy->status;
-                $response->headers       = $snoopy->headers;
-                $response->response_code = trim($snoopy->response_code);
-                $response->results       = $snoopy->results;
-                $response->error         = $snoopy->error;
-                return $response;
-
-            } else if ($snoopy->status != 200) {
-                debugging("Snoopy request for \"$url\" failed, http response code: ".$snoopy->response_code, DEBUG_ALL);
-                return false;
-
-            } else {
-                return $snoopy->results;
-            }
-        } else {
-            if ($fullresponse) {
-                $response = new object();
-                $response->status        = $snoopy->status;
-                $response->headers       = array();
-                $response->response_code = $snoopy->response_code;
-                $response->results       = '';
-                $response->error         = $snoopy->error;
-                return $response;
-            } else {
-                debugging("Snoopy request for \"$url\" failed with: ".$snoopy->error, DEBUG_ALL);
-                return false;
-            }
-        }
-    }
-
     // set extra headers
     if (is_array($headers) ) {
         $headers2 = array();
index 787f6dfbd6522825309d57122ad61d335e65f618..6d3c299d3740bfb8542f90f9049d8ae8440de613 100644 (file)
@@ -402,56 +402,6 @@ function resource_get_coursemodule_info($coursemodule) {
    return $info;
 }
 
-function resource_fetch_remote_file ($cm, $url, $headers = "" ) {
-/// Snoopy is an HTTP client in PHP
-
-    global $CFG;
-
-    require_once("$CFG->libdir/snoopy/Snoopy.class.inc");
-
-    $client = new Snoopy();
-    $ua = 'Moodle/'. $CFG->release . ' (+http://moodle.org';
-    if ( $CFG->resource_usecache ) {
-        $ua = $ua . ')';
-    } else {
-        $ua = $ua . '; No cache)';
-    }
-    $client->agent = $ua;
-    $client->read_timeout = 5;
-    $client->use_gzip = true;
-    if (is_array($headers) ) {
-        $client->rawheaders = $headers;
-    }
-
-    @$client->fetch($url);
-    if ( $client->status >= 200 && $client->status < 300 ) {
-        $tags = array("A"      => "href=",
-                      "IMG"    => "src=",
-                      "LINK"   => "href=",
-                      "AREA"   => "href=",
-                      "FRAME"  => "src=",
-                      "IFRAME" => "src=",
-                      "FORM"   => "action=");
-
-        foreach ($tags as $tag => $key) {
-            $prefix = "fetch.php?id=$cm->id&amp;url=";
-            if ( $tag == "IMG" or $tag == "LINK" or $tag == "FORM") {
-                $prefix = "";
-            }
-            $client->results = resource_redirect_tags($client->results, $url, $tag, $key,$prefix);
-        }
-    } else {
-        if ( $client->status >= 400 && $client->status < 500) {
-            $client->results = get_string("fetchclienterror","resource");  // Client error
-        } elseif ( $client->status >= 500 && $client->status < 600) {
-            $client->results = get_string("fetchservererror","resource");  // Server error
-        } else {
-            $client->results = get_string("fetcherror","resource");     // Redirection? HEAD? Unknown error.
-        }
-    }
-    return $client;
-}
-
 function resource_redirect_tags($text, $url, $tagtoparse, $keytoparse,$prefix = "" ) {
     $valid = 1;
     if ( strpos($url,"?") == FALSE ) {