]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14406
authorthepurpleblob <thepurpleblob>
Wed, 30 Apr 2008 14:35:32 +0000 (14:35 +0000)
committerthepurpleblob <thepurpleblob>
Wed, 30 Apr 2008 14:35:32 +0000 (14:35 +0000)
MNET can now establish a peer through a proxy

Merged from STABLE_19

lang/en_utf8/error.php
mnet/lib.php
mnet/peer.php

index e8ef851b4385e4a09a524cc23aab29aefd210e61..56480d66e2228d3ba51e233f39264fd9aefb9deb 100644 (file)
@@ -161,6 +161,7 @@ $string['sendmessage'] = 'Send Message';
 $string['sessionerroruser'] = 'Your session has timed out.  Please login again.';
 $string['sessionerroruser2'] = 'A server error that affects your login session was detected. Please login again or restart your browser.';
 $string['sessionipnomatch'] = 'Sorry, but your IP number seems to have changed from when you first logged in.  This security feature prevents crackers stealing your identity while logged in to this site.  Normal users should not be seeing this message - please ask the site administrator for help.';
+$string['socksnotsupported'] = 'SOCKS5 proxy is not supported in PHP4';
 $string['statscatchupmode'] = 'Statistics is currently in catchup mode. So far $a->daysdone day(s) have been processed and $a->dayspending are pending. Check back soon!';
 $string['tagnotfound'] = 'The specified tag was not found in the database';
 $string['unicodeupgradeerror'] = 'Sorry, but your database is not already in Unicode, and this version of Moodle is not able to migrate your database to Unicode.  Please upgrade to Moodle 1.7.x first and perform the Unicode migration from the Admin page.  After that is done you should be able to migrate to Moodle $a';
index ef8dd4783ee8463839e250cd28c757480e939a36..1c848e3112c56e6b737c298a8b6131999c334821 100644 (file)
@@ -70,6 +70,35 @@ function mnet_get_public_key($uri, $application=null) {
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
 
+    // check for proxy
+    if (!empty($CFG->proxyhost)) {
+        // SOCKS supported in PHP5 only
+        if (!empty($CFG->proxytype) and ($CFG->proxytype == 'SOCKS5')) {
+            if (defined('CURLPROXY_SOCKS5')) {
+                curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+            } else {
+                curl_close($ch);
+                print_error( 'socksnotsupported','mnet' );
+            }
+        }
+
+        curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, false);
+
+        if (empty($CFG->proxyport)) {
+            curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost);
+        } else {
+            curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost.':'.$CFG->proxyport);
+        }
+
+        if (!empty($CFG->proxyuser) and !empty($CFG->proxypassword)) {
+            curl_setopt($ch, CURLOPT_PROXYUSERPWD, $CFG->proxyuser.':'.$CFG->proxypassword);
+            if (defined('CURLOPT_PROXYAUTH')) {
+                // any proxy authentication if PHP 5.1
+                curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC | CURLAUTH_NTLM);
+            }
+        }
+    }
+
     $res = xmlrpc_decode(curl_exec($ch));
     curl_close($ch);
 
@@ -491,7 +520,7 @@ function mnet_update_sso_access_control($username, $mnet_host_id, $accessctrl) {
             add_to_log(SITEID, 'admin/mnet', 'update', 'admin/mnet/access_control.php',
                     "SSO ACL: $accessctrl user '$username' from {$mnethost->name}");
         } else {
-            error(get_string('failedaclwrite','mnet', $username));
+            print_error('failedaclwrite', 'mnet', '', $username);
             return false;
         }
     } else {
@@ -503,7 +532,7 @@ function mnet_update_sso_access_control($username, $mnet_host_id, $accessctrl) {
             add_to_log(SITEID, 'admin/mnet', 'add', 'admin/mnet/access_control.php',
                     "SSO ACL: $accessctrl user '$username' from {$mnethost->name}");
         } else {
-            error(get_string('failedaclwrite','mnet', $username));
+            print_error('failedaclwrite', 'mnet', '', $username);
             return false;
         }
     }
index 6731d3d534281ecdf7133663a9c3febccb7d913a..3512951bb8f4b291799463f13b0b6128c9aea88c 100644 (file)
@@ -51,7 +51,7 @@ class mnet_peer {
 
             // TODO: In reality, this will be prohibitively slow... need another
             // default - maybe blank string
-            $homepage = file_get_contents($wwwroot);
+            $homepage = download_file_content($wwwroot);
             if (!empty($homepage)) {
                 $count = preg_match("@<title>(.*)</title>@siU", $homepage, $matches);
                 if ($count > 0) {