Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
1 Index: includes/bootstrap.inc
2 --- includes/bootstrap.inc.orig 2008-02-11 15:36:21 +0100
3 +++ includes/bootstrap.inc 2008-04-09 20:47:49 +0200
4 @@ -730,6 +730,7 @@
5 */
6 function drupal_settings_initialize() {
7 global $base_url, $base_path, $base_root;
8 + global $base_url_local;
10 // Export the following settings.php variables to the global namespace
11 global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url;
12 @@ -1613,8 +1614,22 @@
13 * equivalent using other environment variables.
14 */
15 function request_uri() {
16 + global $base_url;
17 + global $base_url_local;
18 +
19 if (isset($_SERVER['REQUEST_URI'])) {
20 $uri = $_SERVER['REQUEST_URI'];
21 + if (isset($base_url) && isset($base_url_local)) {
22 + $parts = parse_url($base_url_local);
23 + if ( strlen($uri) >= strlen($base_url_local)
24 + && substr($uri, 0, strlen($base_url_local)) == $base_url_local) {
25 + $uri = $base_url . substr($uri, strlen($base_url_local));
26 + }
27 + elseif ( strlen($uri) >= strlen($parts["path"])
28 + && substr($uri, 0, strlen($parts["path"])) == $parts["path"]) {
29 + $uri = $base_url . substr($uri, strlen($parts["path"]));
30 + }
31 + }
32 }
33 else {
34 if (isset($_SERVER['argv'])) {
35 @@ -1628,6 +1643,7 @@
36 }
37 }
38 // Prevent multiple slashes to avoid cross site requests via the Form API.
39 + if (substr($uri, 0, 1) == "/")
40 $uri = '/' . ltrim($uri, '/');
42 return $uri;
43 Index: includes/common.inc
44 --- includes/common.inc.orig 2008-04-09 23:11:44 +0200
45 +++ includes/common.inc 2008-06-26 20:16:16 +0200
46 @@ -848,9 +848,14 @@
47 }
49 // Construct the path to act on.
50 - $path = isset($uri['path']) ? $uri['path'] : '/';
51 - if (isset($uri['query'])) {
52 - $path .= '?' . $uri['query'];
53 + if (variable_get('proxy_server', '') != '') {
54 + $path = $url;
55 + }
56 + else {
57 + $path = isset($uri['path']) ? $uri['path'] : '/';
58 + if (isset($uri['query'])) {
59 + $path .= '?'. $uri['query'];
60 + }
61 }
63 // Merge the default headers.
64 @@ -872,6 +877,14 @@
65 $options['headers']['Authorization'] = 'Basic ' . base64_encode($uri['user'] . (isset($uri['pass']) ? ':' . $uri['pass'] : ''));
66 }
68 + // If the proxy server required a username then attempt to authenticate with it
69 + if (variable_get('proxy_username', '') != '') {
70 + $username = variable_get('proxy_username', '');
71 + $password = variable_get('proxy_password', '');
72 + $auth_string = base64_encode($username . ($password != '' ? ':'. $password : ''));
73 + $defaults['Proxy-Authorization'] = 'Proxy-Authorization: Basic '. $auth_string ."\r\n";
74 + }
75 +
76 // If the database prefix is being used by SimpleTest to run the tests in a copied
77 // database then set the user-agent header to the database prefix so that any
78 // calls to other Drupal pages will run the SimpleTest prefixed database. The
79 Index: modules/system/system.admin.inc
80 --- modules/system/system.admin.inc.orig 2012-10-17 22:45:04.000000000 +0200
81 +++ modules/system/system.admin.inc 2012-10-27 13:56:02.343450754 +0200
82 @@ -1766,6 +1766,65 @@
83 }
85 /**
86 + * Form builder; Configure the site proxy settings.
87 + *
88 + * @ingroup forms
89 + * @see system_settings_form()
90 + */
91 +function system_proxy_settings() {
92 +
93 + $form['forward_proxy'] = array(
94 + '#type' => 'fieldset',
95 + '#title' => t('Forward proxy settings'),
96 + '#description' => t('The proxy server used when Drupal needs to connect to other sites on the Internet.'),
97 + );
98 + $form['forward_proxy']['proxy_server'] = array(
99 + '#type' => 'textfield',
100 + '#title' => t('Proxy host name'),
101 + '#default_value' => variable_get('proxy_server', ''),
102 + '#description' => t('The host name of the proxy server, eg. localhost. If this is empty Drupal will connect directly to the internet.')
103 + );
104 + $form['forward_proxy']['proxy_port'] = array(
105 + '#type' => 'textfield',
106 + '#title' => t('Proxy port number'),
107 + '#default_value' => variable_get('proxy_port', 8080),
108 + '#description' => t('The port number of the proxy server, eg. 8080'),
109 + );
110 + $form['forward_proxy']['proxy_username'] = array(
111 + '#type' => 'textfield',
112 + '#title' => t('Proxy username'),
113 + '#default_value' => variable_get('proxy_username', ''),
114 + '#description' => t('The username used to authenticate with the proxy server.'),
115 + );
116 + $form['forward_proxy']['proxy_password'] = array(
117 + '#type' => 'textfield',
118 + '#title' => t('Proxy password'),
119 + '#default_value' => variable_get('proxy_password', ''),
120 + '#description' => t('The password used to connect to the proxy server. This is kept as plain text.', '')
121 + );
122 + $form['#validate'][] = 'system_proxy_settings_validate';
123 +
124 + return system_settings_form($form);
125 +}
126 +
127 +/**
128 + * Validate the submitted proxy form.
129 + */
130 +function system_proxy_settings_validate($form, &$form_state) {
131 + // Validate the proxy settings
132 + $form_state['values']['proxy_server'] = trim($form_state['values']['proxy_server']);
133 + if ($form_state['values']['proxy_server'] != '') {
134 + // TCP allows the port to be between 0 and 65536 inclusive
135 + if (!is_numeric($form_state['values']['proxy_port'])) {
136 + form_set_error('proxy_port', t('The proxy port is invalid. It must be a number between 0 and 65535.'));
137 + }
138 + elseif ($form_state['values']['proxy_port'] < 0 || $form_state['values']['proxy_port'] >= 65536) {
139 + form_set_error('proxy_port', t('The proxy port is invalid. It must be between 0 and 65535.'));
140 + }
141 + }
142 +}
143 +
144 +/**
145 * Form builder; Configure the site file handling.
146 *
147 * @ingroup forms
148 Index: modules/system/system.module
149 --- modules/system/system.module.orig 2008-04-09 23:11:49 +0200
150 +++ modules/system/system.module 2008-04-24 11:43:47 +0200
151 @@ -723,6 +723,14 @@
152 'access arguments' => array('access administration pages'),
153 'file' => 'system.admin.inc',
154 );
155 + $items['admin/settings/proxy'] = array(
156 + 'title' => 'Proxy server',
157 + 'description' => 'Configure settings when the site is behind a proxy server.',
158 + 'page callback' => 'drupal_get_form',
159 + 'page arguments' => array('system_proxy_settings'),
160 + 'access arguments' => array('administer site configuration'),
161 + 'file' => 'system.admin.inc',
162 + );
163 $items['admin/config/media/file-system'] = array(
164 'title' => 'File system',
165 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
166 Index: includes/install.core.inc
167 --- includes/install.core.inc.orig 2012-08-01 18:27:42.000000000 +0200
168 +++ includes/install.core.inc 2012-08-22 21:55:27.582420660 +0200
169 @@ -1770,7 +1770,7 @@
170 1 => st('Check for updates automatically'),
171 2 => st('Receive e-mail notifications'),
172 ),
173 - '#default_value' => array(1, 2),
174 + '#default_value' => array(),
175 '#description' => st('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to <a href="@drupal">Drupal.org</a>.', array('@drupal' => 'http://drupal.org')),
176 '#weight' => 15,
177 );
178 Index: sites/default/default.settings.php
179 --- sites/default/default.settings.php.orig 2012-08-01 18:27:42.000000000 +0200
180 +++ sites/default/default.settings.php 2012-08-22 21:39:06.793031214 +0200
181 @@ -257,6 +257,24 @@
182 # $base_url = 'http://www.example.com'; // NO trailing slash!
184 /**
185 + * Local Base URL (optional).
186 + *
187 + * If you are running Drupal behind a reverse proxy, $base_url (see above)
188 + * usually points to the URL of the reverse proxy. Drupal uses this for
189 + * all sorts of external URLs. In order to correctly calculate sub-URLs
190 + * below $base_url for embedded HTML forms, Drupal also has to know the
191 + * URL on the local/origin server under which Drupal is contacted by the
192 + * reverse proxy. This is what $base_url_local is for.
193 + *
194 + * Examples:
195 + * $base_url_local = 'http://www.example.com:8080/drupal';
196 + *
197 + * It is not allowed to have a trailing slash; Drupal will add it
198 + * for you.
199 + */
200 +# $base_url_local = 'http://www.example.com:8080/drupal'; // NO trailing slash!
201 +
202 +/**
203 * PHP settings:
204 *
205 * To see what PHP settings are possible, including whether they can be set at