Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-14406

MNET can now establish a peer through a proxy
  • Loading branch information...
commit 9c3c1ab56d474bc82cd094615ece00f388a668ae 1 parent 2c9a36d
authored April 30, 2008
1  lang/en_utf8/error.php
@@ -94,6 +94,7 @@
94 94
 $string['sessionerroruser'] = 'Your session has timed out.  Please login again.';
95 95
 $string['sessionerroruser2'] = 'A server error that affects your login session was detected. Please login again or restart your browser.';
96 96
 $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.';
  97
+$string['socksnotsupported'] = 'SOCKS5 proxy is not supported in PHP4';
97 98
 $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!';
98 99
 $string['tagnotfound'] = 'The specified tag was not found in the database';
99 100
 $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';
29  mnet/lib.php
@@ -70,6 +70,35 @@ function mnet_get_public_key($uri, $application=null) {
70 70
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
71 71
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
72 72
 
  73
+    // check for proxy
  74
+    if (!empty($CFG->proxyhost)) {
  75
+        // SOCKS supported in PHP5 only
  76
+        if (!empty($CFG->proxytype) and ($CFG->proxytype == 'SOCKS5')) {
  77
+            if (defined('CURLPROXY_SOCKS5')) {
  78
+                curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  79
+            } else {
  80
+                curl_close($ch);
  81
+                print_error( 'socksnotsupported','mnet' );
  82
+            }
  83
+        }
  84
+
  85
+        curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, false);
  86
+
  87
+        if (empty($CFG->proxyport)) {
  88
+            curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost);
  89
+        } else {
  90
+            curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost.':'.$CFG->proxyport);
  91
+        }
  92
+
  93
+        if (!empty($CFG->proxyuser) and !empty($CFG->proxypassword)) {
  94
+            curl_setopt($ch, CURLOPT_PROXYUSERPWD, $CFG->proxyuser.':'.$CFG->proxypassword);
  95
+            if (defined('CURLOPT_PROXYAUTH')) {
  96
+                // any proxy authentication if PHP 5.1
  97
+                curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC | CURLAUTH_NTLM);
  98
+            }
  99
+        }
  100
+    }
  101
+
73 102
     $res = xmlrpc_decode(curl_exec($ch));
74 103
     curl_close($ch);
75 104
 
2  mnet/peer.php
@@ -51,7 +51,7 @@ function bootstrap($wwwroot, $pubkey = null, $application) {
51 51
 
52 52
             // TODO: In reality, this will be prohibitively slow... need another
53 53
             // default - maybe blank string
54  
-            $homepage = file_get_contents($wwwroot);
  54
+            $homepage = download_file_content($wwwroot);
55 55
             if (!empty($homepage)) {
56 56
                 $count = preg_match("@<title>(.*)</title>@siU", $homepage, $matches);
57 57
                 if ($count > 0) {

0 notes on commit 9c3c1ab

Please sign in to comment.
Something went wrong with that request. Please try again.