? profiles/egressive
? profiles/install_profile_api
? sites/base
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.759
diff -u -r1.759 common.inc
--- includes/common.inc	20 Feb 2008 13:38:32 -0000	1.759
+++ includes/common.inc	28 Feb 2008 21:19:35 -0000
@@ -439,7 +439,14 @@
     case 'http':
       $port = isset($uri['port']) ? $uri['port'] : 80;
       $host = $uri['host'] . ($port != 80 ? ':'. $port : '');
-      $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
+      if (variable_get('proxy_server', '') != '') {
+        $proxy_server = variable_get('proxy_server', '');
+        $proxy_port = variable_get('proxy_port', 8080);
+        $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15);
+      }
+      else {
+        $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
+      }
       break;
     case 'https':
       // Note: Only works for PHP 4.3 compiled with OpenSSL.
@@ -462,9 +469,14 @@
   }
 
   // Construct the path to act on.
-  $path = isset($uri['path']) ? $uri['path'] : '/';
-  if (isset($uri['query'])) {
-    $path .= '?'. $uri['query'];
+  if (variable_get('proxy_server', '') != '') {
+    $path = $url;
+  }
+  else {
+    $path = isset($uri['path']) ? $uri['path'] : '/';
+    if (isset($uri['query'])) {
+      $path .= '?'. $uri['query'];
+    }
   }
 
   // Create HTTP request.
@@ -482,6 +494,14 @@
     $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
   }
 
+  // If the proxy server required a username then attempt to authenticate with it
+  if (variable_get('proxy_username', '') != '') {
+    $username = variable_get('proxy_username', '');
+    $password = variable_get('proxy_password', '');
+    $auth_string = base64_encode($username . ($password != '' ? ':'. $password : ''));
+    $defaults['Proxy-Authorization'] = 'Proxy-Authorization: Basic '. $auth_string ."\r\n";
+  }
+
   foreach ($headers as $header => $value) {
     $defaults[$header] = $header .': '. $value;
   }
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.64
diff -u -r1.64 system.admin.inc
--- modules/system/system.admin.inc	20 Feb 2008 13:46:41 -0000	1.64
+++ modules/system/system.admin.inc	28 Feb 2008 21:19:39 -0000
@@ -1160,6 +1160,30 @@
     '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
     '#required' => TRUE,
   );
+  $form['proxy_server'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Proxy host name'),
+    '#default_value' => variable_get('proxy_server', ''),
+    '#description' => t('The host name of the proxy server.')
+  );
+  $form['proxy_port'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Proxy port number'),
+    '#default_value' => variable_get('proxy_port', 8080),
+    '#description' => t('The port number of the proxy server.'),
+  );
+  $form['proxy_username'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Proxy username'),
+    '#default_value' => variable_get('proxy_username', ''),
+    '#description' => t('The username for the proxy server.'),
+  );
+  $form['proxy_password'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Proxy password'),
+    '#default_value' => variable_get('proxy_password', ''),
+    '#description' => t('The password for the proxy server', '')
+  );
   $form['#validate'][] = 'system_site_information_settings_validate';
 
   return system_settings_form($form);
@@ -1183,6 +1207,16 @@
   if (!empty($item) && !menu_valid_path($item)) {
     form_set_error('site_frontpage', t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $item['link_path'])));
   }
+  // Validate the proxy settings
+  if ($form_state['values']['proxy_server'] != '') {
+    // TCP allows the port to be between 0 and 65536 inclusive
+    if (!is_numeric($form_state['values']['proxy_port'])) {
+      form_set_error('proxy_port', t('The proxy port is invalid. It must be a number between 0 and 65535.'));
+    }
+    elseif ($form_state['values']['proxy_port'] < 0 || $form_state['values']['proxy_port'] >= 65536) {
+      form_set_error('proxy_port', t('The proxy port is invalid. It must be between 0 and 65535.'));
+    }
+  }
 }
 
 /**
