]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11845 Updated the three file downloads from Snoopy to download_file_content ...
authorsam_marshall <sam_marshall>
Fri, 7 Dec 2007 10:24:00 +0000 (10:24 +0000)
committersam_marshall <sam_marshall>
Fri, 7 Dec 2007 10:24:00 +0000 (10:24 +0000)
admin/timezoneimport.php
lib/componentlib.class.php

index 086d95525eb09909a7bd8e67ded118d8b5150146..b38ecdbbed720570246e4e6631fac757ba817de4 100644 (file)
@@ -6,7 +6,6 @@
     require_once($CFG->libdir.'/adminlib.php');
     require_once($CFG->libdir.'/filelib.php');
     require_once($CFG->libdir.'/olson.php');
-    require_once($CFG->libdir.'/snoopy/Snoopy.class.inc');
     
     admin_externalpage_setup('timezoneimport');
 
     }
 
 /// Otherwise, let's try moodle.org's copy
-    $snoopy = new Snoopy;
-    $snoopy->proxy_host = $CFG->proxyhost;
-    $snoopy->proxy_port = $CFG->proxyport;
-
     $source = 'http://download.moodle.org/timezones/';
-    if (!$importdone && $snoopy->fetch($source)) {
+    if (!$importdone && ($content=download_file_content($source))) {
         if ($file = fopen($CFG->dataroot.'/temp/timezones.txt', 'w')) {            // Make local copy
-            fwrite($file, $snoopy->results);
+            fwrite($file, $content);
             fclose($file);
             if ($timezones = get_records_csv($CFG->dataroot.'/temp/timezones.txt', 'timezone')) {  // Parse it
                 update_timezone_records($timezones);
@@ -82,7 +77,6 @@
 
 
 /// Final resort, use the copy included in Moodle
-
     $source = $CFG->dirroot.'/lib/timezones.txt';
     if (!$importdone and is_readable($source)) {  // Distribution file
         if ($timezones = get_records_csv($source, 'timezone')) {
index c899a7596d01c241fb299b2a0d1e8ace701210f3..b79214798fc9c2d5569c66d769525a77f2f119e8 100644 (file)
 // error to be retrieved by one standard get_string() call against the error.php lang file.
 //
 // That's all!
-global $CFG;
-require_once($CFG->libdir.'/snoopy/Snoopy.class.inc');
 
 // Some needed constants
 define('ERROR',           0);
@@ -274,13 +272,7 @@ class component_installer {
         $source = $this->sourcebase.'/'.$this->zippath.'/'.$this->zipfilename;
         $zipfile= $CFG->dataroot.'/temp/'.$this->zipfilename;
 
-    /// Prepare Snoopy client and set up proxy info
-        $snoopy = new Snoopy;
-        global $CFG;
-        $snoopy->proxy_host = $CFG->proxyhost;
-        $snoopy->proxy_port = $CFG->proxyport;
-        if($snoopy->fetch($source)) {
-            $contents = $snoopy->results;
+        if($contents = download_file_content($source)) {
             if ($file = fopen($zipfile, 'w')) {
                 if (!fwrite($file, $contents)) {
                     fclose($file);
@@ -468,15 +460,9 @@ class component_installer {
         /// Not downloaded, let's do it now
             $availablecomponents = array();
 
-            /// Prepare Snoopy client and set up proxy info
-            $snoopy = new Snoopy;
-            global $CFG;
-            $snoopy->proxy_host = $CFG->proxyhost;
-            $snoopy->proxy_port = $CFG->proxyport;
-
-            if ($snoopy->fetch($source)) {
+            if ($contents = download_file_content($source)) {
             /// Split text into lines
-                $lines=preg_split('/\r?\n/',$snoopy->results);
+                $lines=preg_split('/\r?\n/',$contents);
             /// Each line will be one component
                 foreach($lines as $line) {
                     $availablecomponents[] = split(',', $line);