drupal.patch 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. Fix Reverse Proxy Support:
  2. http://drupal.org/node/244593
  3. http://drupal.org/files/issues/drupal_80.patch
  4. Index: includes/bootstrap.inc
  5. --- includes/bootstrap.inc.orig 2008-02-11 15:36:21 +0100
  6. +++ includes/bootstrap.inc 2008-04-09 20:47:49 +0200
  7. @@ -272,6 +272,7 @@
  8. */
  9. function conf_init() {
  10. global $base_url, $base_path, $base_root;
  11. + global $base_url_local;
  12. // Export the following settings.php variables to the global namespace
  13. global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access;
  14. @@ -723,9 +724,22 @@
  15. * generate an equivalent using other environment variables.
  16. */
  17. function request_uri() {
  18. + global $base_url;
  19. + global $base_url_local;
  20. if (isset($_SERVER['REQUEST_URI'])) {
  21. $uri = $_SERVER['REQUEST_URI'];
  22. + if (isset($base_url) && isset($base_url_local)) {
  23. + $parts = parse_url($base_url_local);
  24. + if ( strlen($uri) >= strlen($base_url_local)
  25. + && substr($uri, 0, strlen($base_url_local)) == $base_url_local) {
  26. + $uri = $base_url . substr($uri, strlen($base_url_local));
  27. + }
  28. + elseif ( strlen($uri) >= strlen($parts["path"])
  29. + && substr($uri, 0, strlen($parts["path"])) == $parts["path"]) {
  30. + $uri = $base_url . substr($uri, strlen($parts["path"]));
  31. + }
  32. + }
  33. }
  34. else {
  35. if (isset($_SERVER['argv'])) {
  36. Index: sites/default/default.settings.php
  37. --- sites/default/default.settings.php.orig 2007-12-20 10:35:10 +0100
  38. +++ sites/default/default.settings.php 2008-04-09 20:47:32 +0200
  39. @@ -126,6 +126,24 @@
  40. # $base_url = 'http://www.example.com'; // NO trailing slash!
  41. /**
  42. + * Local Base URL (optional).
  43. + *
  44. + * If you are running Drupal behind a reverse proxy, $base_url (see above)
  45. + * usually points to the URL of the reverse proxy. Drupal uses this for
  46. + * all sorts of external URLs. In order to correctly calculate sub-URLs
  47. + * below $base_url for embedded HTML forms, Drupal also has to know the
  48. + * URL on the local/origin server under which Drupal is contacted by the
  49. + * reverse proxy. This is what $base_url_local is for.
  50. + *
  51. + * Examples:
  52. + * $base_url_local = 'http://www.example.com:8080/drupal';
  53. + *
  54. + * It is not allowed to have a trailing slash; Drupal will add it
  55. + * for you.
  56. + */
  57. +# $base_url_local = 'http://www.example.com:8080/drupal'; // NO trailing slash!
  58. +
  59. +/**
  60. * PHP settings:
  61. *
  62. * To see what PHP settings are possible, including whether they can
  63. -----------------------------------------------------------------------------
  64. Support HTTP Proxies (mainly for update checks, RSS fetching, etc)
  65. http://drupal.org/node/7881
  66. http://drupal.org/files/issues/proxy_11.patch
  67. (post-adjusted and improved by RSE)
  68. Index: includes/common.inc
  69. --- includes/common.inc.orig 2008-04-09 23:11:44 +0200
  70. +++ includes/common.inc 2008-04-24 11:41:40 +0200
  71. @@ -439,13 +439,27 @@
  72. case 'http':
  73. $port = isset($uri['port']) ? $uri['port'] : 80;
  74. $host = $uri['host'] . ($port != 80 ? ':'. $port : '');
  75. - $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
  76. + if (variable_get('proxy_server', '') != '') {
  77. + $proxy_server = variable_get('proxy_server', '');
  78. + $proxy_port = variable_get('proxy_port', 8080);
  79. + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15);
  80. + }
  81. + else {
  82. + $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
  83. + }
  84. break;
  85. case 'https':
  86. // Note: Only works for PHP 4.3 compiled with OpenSSL.
  87. $port = isset($uri['port']) ? $uri['port'] : 443;
  88. $host = $uri['host'] . ($port != 443 ? ':'. $port : '');
  89. - $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
  90. + if (variable_get('proxy_server', '') != '') {
  91. + $proxy_server = variable_get('proxy_server', '');
  92. + $proxy_port = variable_get('proxy_port', 8080);
  93. + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15);
  94. + }
  95. + else {
  96. + $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
  97. + }
  98. break;
  99. default:
  100. $result->error = 'invalid schema '. $uri['scheme'];
  101. @@ -462,9 +476,14 @@
  102. }
  103. // Construct the path to act on.
  104. - $path = isset($uri['path']) ? $uri['path'] : '/';
  105. - if (isset($uri['query'])) {
  106. - $path .= '?'. $uri['query'];
  107. + if (variable_get('proxy_server', '') != '') {
  108. + $path = $url;
  109. + }
  110. + else {
  111. + $path = isset($uri['path']) ? $uri['path'] : '/';
  112. + if (isset($uri['query'])) {
  113. + $path .= '?'. $uri['query'];
  114. + }
  115. }
  116. // Create HTTP request.
  117. @@ -482,6 +501,14 @@
  118. $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
  119. }
  120. + // If the proxy server required a username then attempt to authenticate with it
  121. + if (variable_get('proxy_username', '') != '') {
  122. + $username = variable_get('proxy_username', '');
  123. + $password = variable_get('proxy_password', '');
  124. + $auth_string = base64_encode($username . ($password != '' ? ':'. $password : ''));
  125. + $defaults['Proxy-Authorization'] = 'Proxy-Authorization: Basic '. $auth_string ."\r\n";
  126. + }
  127. +
  128. foreach ($headers as $header => $value) {
  129. $defaults[$header] = $header .': '. $value;
  130. }
  131. Index: modules/system/system.admin.inc
  132. --- modules/system/system.admin.inc.orig 2008-03-25 12:58:16 +0100
  133. +++ modules/system/system.admin.inc 2008-04-24 11:43:07 +0200
  134. @@ -1363,6 +1363,65 @@
  135. }
  136. /**
  137. + * Form builder; Configure the site proxy settings.
  138. + *
  139. + * @ingroup forms
  140. + * @see system_settings_form()
  141. + */
  142. +function system_proxy_settings() {
  143. +
  144. + $form['forward_proxy'] = array(
  145. + '#type' => 'fieldset',
  146. + '#title' => t('Forward proxy settings'),
  147. + '#description' => t('The proxy server used when Drupal needs to connect to other sites on the Internet.'),
  148. + );
  149. + $form['forward_proxy']['proxy_server'] = array(
  150. + '#type' => 'textfield',
  151. + '#title' => t('Proxy host name'),
  152. + '#default_value' => variable_get('proxy_server', ''),
  153. + '#description' => t('The host name of the proxy server, eg. localhost. If this is empty Drupal will connect directly to the internet.')
  154. + );
  155. + $form['forward_proxy']['proxy_port'] = array(
  156. + '#type' => 'textfield',
  157. + '#title' => t('Proxy port number'),
  158. + '#default_value' => variable_get('proxy_port', 8080),
  159. + '#description' => t('The port number of the proxy server, eg. 8080'),
  160. + );
  161. + $form['forward_proxy']['proxy_username'] = array(
  162. + '#type' => 'textfield',
  163. + '#title' => t('Proxy username'),
  164. + '#default_value' => variable_get('proxy_username', ''),
  165. + '#description' => t('The username used to authenticate with the proxy server.'),
  166. + );
  167. + $form['forward_proxy']['proxy_password'] = array(
  168. + '#type' => 'textfield',
  169. + '#title' => t('Proxy password'),
  170. + '#default_value' => variable_get('proxy_password', ''),
  171. + '#description' => t('The password used to connect to the proxy server. This is kept as plain text.', '')
  172. + );
  173. + $form['#validate'][] = 'system_proxy_settings_validate';
  174. +
  175. + return system_settings_form($form);
  176. +}
  177. +
  178. +/**
  179. + * Validate the submitted proxy form.
  180. + */
  181. +function system_proxy_settings_validate($form, &$form_state) {
  182. + // Validate the proxy settings
  183. + $form_state['values']['proxy_server'] = trim($form_state['values']['proxy_server']);
  184. + if ($form_state['values']['proxy_server'] != '') {
  185. + // TCP allows the port to be between 0 and 65536 inclusive
  186. + if (!is_numeric($form_state['values']['proxy_port'])) {
  187. + form_set_error('proxy_port', t('The proxy port is invalid. It must be a number between 0 and 65535.'));
  188. + }
  189. + elseif ($form_state['values']['proxy_port'] < 0 || $form_state['values']['proxy_port'] >= 65536) {
  190. + form_set_error('proxy_port', t('The proxy port is invalid. It must be between 0 and 65535.'));
  191. + }
  192. + }
  193. +}
  194. +
  195. +/**
  196. * Form builder; Configure the site file handling.
  197. *
  198. * @ingroup forms
  199. Index: modules/system/system.module
  200. --- modules/system/system.module.orig 2008-04-09 23:11:49 +0200
  201. +++ modules/system/system.module 2008-04-24 11:43:47 +0200
  202. @@ -55,7 +55,7 @@
  203. $output .= '<li>'. t('support for enabling and disabling <a href="@themes">themes</a>, which determine the design and presentation of your site. Drupal comes packaged with several core themes and additional contributed themes are available at the <a href="@drupal-themes">Drupal.org theme page</a>.', array('@themes' => url('admin/build/themes'), '@drupal-themes' => 'http://drupal.org/project/themes')) .'</li>';
  204. $output .= '<li>'. t('a robust <a href="@cache-settings">caching system</a> that allows the efficient re-use of previously-constructed web pages and web page components. Drupal stores the pages requested by anonymous users in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, Drupal\'s caching system may significantly increase the speed of your site.', array('@cache-settings' => url('admin/settings/performance'))) .'</li>';
  205. $output .= '<li>'. t('a set of routine administrative operations that rely on a correctly-configured <a href="@cron">cron maintenance task</a> to run automatically. A number of other modules, including the feed aggregator, ping module and search also rely on <a href="@cron">cron maintenance tasks</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>.', array('@cron' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron')) .'</li>';
  206. - $output .= '<li>'. t('basic configuration options for your site, including <a href="@date-settings">date and time settings</a>, <a href="@file-system">file system settings</a>, <a href="@clean-url">clean URL support</a>, <a href="@site-info">site name and other information</a>, and a <a href="@site-maintenance">site maintenance</a> function for taking your site temporarily off-line.', array('@date-settings' => url('admin/settings/date-time'), '@file-system' => url('admin/settings/file-system'), '@clean-url' => url('admin/settings/clean-urls'), '@site-info' => url('admin/settings/site-information'), '@site-maintenance' => url('admin/settings/site-maintenance'))) .'</li></ul>';
  207. + $output .= '<li>'. t('basic configuration options for your site, including <a href="@date-settings">date and time settings</a>, <a href="@file-system">file system settings</a>, <a href="@clean-url">clean URL support</a>, <a href="@proxy-server">proxy server settings</a>, a href="@site-info">site name and other information</a>, and a <a href="@site-maintenance">site maintenance</a> function for taking your site temporarily off-line.', array('@date-settings' => url('admin/settings/date-time'), '@file-system' => url('admin/settings/file-system'), '@clean-url' => url('admin/settings/clean-urls'), '@site-info' => url('admin/settings/site-information'), '@site-maintenance' => url('admin/settings/site-maintenance'))) .'</li></ul>';
  208. $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@system">System module</a>.', array('@system' => 'http://drupal.org/handbook/modules/system/')) .'</p>';
  209. return $output;
  210. case 'admin':
  211. @@ -406,6 +406,14 @@
  212. 'access arguments' => array('administer site configuration'),
  213. 'file' => 'system.admin.inc',
  214. );
  215. + $items['admin/settings/proxy'] = array(
  216. + 'title' => 'Proxy server',
  217. + 'description' => 'Configure settings when the site is behind a proxy server.',
  218. + 'page callback' => 'drupal_get_form',
  219. + 'page arguments' => array('system_proxy_settings'),
  220. + 'access arguments' => array('administer site configuration'),
  221. + 'file' => 'system.admin.inc',
  222. + );
  223. $items['admin/settings/file-system'] = array(
  224. 'title' => 'File system',
  225. 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
  226. -----------------------------------------------------------------------------
  227. Properly activate Drupal support module in TinyMCE
  228. Index: sites/all/modules/tinymce/plugin_reg.php
  229. --- sites/all/modules/tinymce/plugin_reg.php.orig 2008-03-27 21:11:17 +0100
  230. +++ sites/all/modules/tinymce/plugin_reg.php 2008-05-02 20:56:56 +0200
  231. @@ -102,5 +102,9 @@
  232. $plugins['zoom'] = array();
  233. $plugins['zoom']['theme_advanced_buttons2'] = array('zoom');
  234. +$plugins['drupalimage'] = array();
  235. +$plugins['drupalimage']['theme_advanced_buttons1'] = array('drupalimage');
  236. +$plugins['drupalimage']['extended_valid_elements'] = array('img[class|src|border=0|alt|title|width|height|align|name]');
  237. +
  238. return $plugins;
  239. }
  240. -----------------------------------------------------------------------------
  241. Fix SQL in "remove" functionality of "img_assist" module.
  242. http://drupal.org/node/250128
  243. Index: sites/all/modules/img_assist/img_assist.module
  244. --- sites/all/modules/img_assist/img_assist.module.orig 2008-04-06 19:32:33 +0200
  245. +++ sites/all/modules/img_assist/img_assist.module 2008-05-02 21:00:24 +0200
  246. @@ -1239,7 +1239,7 @@
  247. }
  248. function _img_assist_remove($node, $size) {
  249. - $result = db_query("SELECT * FROM {files} f INNER JOIN {image} i WHERE f.fid = i.fid AND i.nid = %d AND f.filename = '%s'", $node->nid, $size['key']);
  250. + $result = db_query("SELECT * FROM {files} f INNER JOIN {image} ON f.fid = i.fid WHERE i.nid = %d AND f.filename = '%s'", $node->nid, $size['key']);
  251. while ($file = db_fetch_object($result)) {
  252. // Never delete original image.
  253. if ($file->filepath != $node->images[IMAGE_ORIGINAL]) {
  254. -----------------------------------------------------------------------------
  255. Optimize "img_assist" module by loading only when necessary.
  256. http://drupal.org/node/55101
  257. Index: sites/all/modules/img_assist/img_assist.js
  258. --- sites/all/modules/img_assist/img_assist.js.orig 2008-04-06 18:43:18 +0200
  259. +++ sites/all/modules/img_assist/img_assist.js 2008-05-02 21:05:56 +0200
  260. @@ -130,6 +130,24 @@
  261. var win = window.open(BASE_URL + 'index.php?q=img_assist/popup/' + nid, 'imagev', 'height='+oy+'-10,width='+ox+',top='+winy+',left='+winx+',scrollbars='+use_scrollbars+',resizable');
  262. }
  263. +function launch_popup(nid, mw, mh) {
  264. + var ox = mw;
  265. + var oy = mh;
  266. + if((ox>=screen.width) || (oy>=screen.height)){
  267. + var ox = screen.width-150;
  268. + var oy = screen.height-150;
  269. + var winx = (screen.width / 2)-(ox / 2);
  270. + var winy = (screen.height / 2)-(oy / 2);
  271. + var use_scrollbars = 1;
  272. + }
  273. + else{
  274. + var winx = (screen.width / 2)-(ox / 2);
  275. + var winy = (screen.height / 2)-(oy / 2);
  276. + var use_scrollbars = 0;
  277. + }
  278. + var win = window.open(BASE_URL + 'index.php?q=img_assist/popup/' + nid, 'imagev', 'height='+oy+'-10,width='+ox+',top='+winy+',left='+winx+',scrollbars='+use_scrollbars+',resizable');
  279. +}
  280. +
  281. function insertImage() {
  282. if (window.opener) {
  283. // Get variables from the fields on the properties frame
  284. Index: sites/all/modules/img_assist/img_assist.module
  285. --- sites/all/modules/img_assist/img_assist.module.orig 2008-05-02 21:04:49 +0200
  286. +++ sites/all/modules/img_assist/img_assist.module 2008-05-02 21:07:24 +0200
  287. @@ -126,7 +126,7 @@
  288. }
  289. // Assign base_path to insert in image source by javascript.
  290. drupal_add_js('var BASE_URL = "'. base_path() .'";', 'inline');
  291. - drupal_add_js($path .'/img_assist.js');
  292. + drupal_add_js($path .'/img_assist_popup.js');
  293. }
  294. /**
  295. @@ -150,6 +150,9 @@
  296. * Add image link underneath textareas.
  297. */
  298. function img_assist_textarea($element) {
  299. + $path = drupal_get_path('module', 'img_assist');
  300. + drupal_add_js($path .'/img_assist.js');
  301. +
  302. $link = variable_get('img_assist_link', 'icon');
  303. if (($link == 'icon') || ($link == 'text')) {
  304. if (_img_assist_textarea_match($element['#id']) && _img_assist_page_match() && !strstr($_GET['q'], 'img_assist')) {
  305. Index: sites/all/modules/img_assist/img_assist_popup.js
  306. --- /dev/null 2008-05-02 21:08:21 +0200
  307. +++ sites/all/modules/img_assist/img_assist_popup.js 2008-05-02 21:05:56 +0200
  308. @@ -0,0 +1,20 @@
  309. +/* $Id: drupal.patch,v 1.7 2008/05/03 08:46:37 rse Exp $ */
  310. +
  311. +function launch_popup(nid, mw, mh) {
  312. + var ox = mw;
  313. + var oy = mh;
  314. + if((ox>=screen.width) || (oy>=screen.height)){
  315. + var ox = screen.width-150;
  316. + var oy = screen.height-150;
  317. + var winx = (screen.width / 2)-(ox / 2);
  318. + var winy = (screen.height / 2)-(oy / 2);
  319. + var use_scrollbars = 1;
  320. + }
  321. + else{
  322. + var winx = (screen.width / 2)-(ox / 2);
  323. + var winy = (screen.height / 2)-(oy / 2);
  324. + var use_scrollbars = 0;
  325. + }
  326. + var win = window.open(BASE_URL + 'index.php?q=img_assist/popup/' + nid, 'imagev', 'height='+oy+'-10,width='+ox+',top='+winy+',left='+winx+',scrollbars='+use_scrollbars+',resizable');
  327. +}
  328. +
  329. -----------------------------------------------------------------------------
  330. Fix file permissions.
  331. http://drupal.org/node/247992
  332. Index: sites/all/modules/img_assist/img_assist.module
  333. --- sites/all/modules/img_assist/img_assist.module.orig 2008-05-02 21:11:15 +0200
  334. +++ sites/all/modules/img_assist/img_assist.module 2008-05-02 21:11:48 +0200
  335. @@ -1230,6 +1230,8 @@
  336. drupal_set_message(t('Unable to create %label image', array('%label' => $size['label'])), 'error');
  337. }
  338. else {
  339. + // Set standard file permissions for webserver-generated files
  340. + @chmod(file_create_path($destination), 0664);
  341. $node->images[$key] = $destination;
  342. _image_insert($node, $key, file_create_path($destination));
  343. }
  344. -----------------------------------------------------------------------------
  345. Activate the Drupal glue code for the FCKeditor filemanager.
  346. Index: sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php
  347. --- sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php.orig 2008-03-25 16:28:24 +0100
  348. +++ sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php 2008-05-02 23:02:23 +0200
  349. @@ -39,6 +39,9 @@
  350. // Attention: The above 'UserFilesPath' must point to the same directory.
  351. $Config['UserFilesAbsolutePath'] = '' ;
  352. +// activate Drupal glue code for filemanager
  353. +require_once "../../../../../filemanager.config.php";
  354. +
  355. // Due to security issues with Apache modules, it is recommended to leave the
  356. // following setting enabled.
  357. $Config['ForceSingleExtension'] = true ;
  358. -----------------------------------------------------------------------------
  359. Degrade the "Update notification" check from ERROR to WARNING severity
  360. as for a packaged Drupal as in OpenPKG the Update notification is less
  361. important and actually confusing anyway. With WARNING one at least still
  362. sees the issue, but under "Administer" one doesn't get the confusing red
  363. error message and longer.
  364. Index: modules/system/system.install
  365. --- modules/system/system.install.orig 2008-02-08 18:07:55 +0100
  366. +++ modules/system/system.install 2008-05-03 10:42:23 +0200
  367. @@ -273,7 +273,7 @@
  368. if (!module_exists('update')) {
  369. $requirements['update status'] = array(
  370. 'value' => $t('Not enabled'),
  371. - 'severity' => REQUIREMENT_ERROR,
  372. + 'severity' => REQUIREMENT_WARNING,
  373. 'description' => $t('Update notifications are not enabled. It is <strong>highly recommended</strong> that you enable the update status module from the <a href="@module">module administration page</a> in order to stay up-to-date on new releases. For more information please read the <a href="@update">Update status handbook page</a>.', array('@update' => 'http://drupal.org/handbook/modules/update', '@module' => url('admin/build/modules'))),
  374. );
  375. }