michael@529: Fix Reverse Proxy Support: michael@529: http://drupal.org/node/244593 michael@529: http://drupal.org/files/issues/drupal_80.patch michael@529: michael@529: Index: includes/bootstrap.inc michael@529: --- includes/bootstrap.inc.orig 2008-02-11 15:36:21 +0100 michael@529: +++ includes/bootstrap.inc 2008-04-09 20:47:49 +0200 michael@529: @@ -272,6 +272,7 @@ michael@529: */ michael@529: function conf_init() { michael@529: global $base_url, $base_path, $base_root; michael@529: + global $base_url_local; michael@529: michael@529: // Export the following settings.php variables to the global namespace michael@529: global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access; michael@529: @@ -723,9 +724,22 @@ michael@529: * generate an equivalent using other environment variables. michael@529: */ michael@529: function request_uri() { michael@529: + global $base_url; michael@529: + global $base_url_local; michael@529: michael@529: if (isset($_SERVER['REQUEST_URI'])) { michael@529: $uri = $_SERVER['REQUEST_URI']; michael@529: + if (isset($base_url) && isset($base_url_local)) { michael@529: + $parts = parse_url($base_url_local); michael@529: + if ( strlen($uri) >= strlen($base_url_local) michael@529: + && substr($uri, 0, strlen($base_url_local)) == $base_url_local) { michael@529: + $uri = $base_url . substr($uri, strlen($base_url_local)); michael@529: + } michael@529: + elseif ( strlen($uri) >= strlen($parts["path"]) michael@529: + && substr($uri, 0, strlen($parts["path"])) == $parts["path"]) { michael@529: + $uri = $base_url . substr($uri, strlen($parts["path"])); michael@529: + } michael@529: + } michael@529: } michael@529: else { michael@529: if (isset($_SERVER['argv'])) { michael@529: @@ -792,6 +806,7 @@ michael@529: } michael@529: } michael@529: // Prevent multiple slashes to avoid cross site requests via the FAPI. michael@529: + if (substr($uri, 0, 1) == "/") michael@529: $uri = '/'. ltrim($uri, '/'); michael@529: michael@529: return $uri; michael@529: Index: sites/default/default.settings.php michael@529: --- sites/default/default.settings.php.orig 2007-12-20 10:35:10 +0100 michael@529: +++ sites/default/default.settings.php 2008-04-09 20:47:32 +0200 michael@529: @@ -126,6 +126,24 @@ michael@529: # $base_url = 'http://www.example.com'; // NO trailing slash! michael@529: michael@529: /** michael@529: + * Local Base URL (optional). michael@529: + * michael@529: + * If you are running Drupal behind a reverse proxy, $base_url (see above) michael@529: + * usually points to the URL of the reverse proxy. Drupal uses this for michael@529: + * all sorts of external URLs. In order to correctly calculate sub-URLs michael@529: + * below $base_url for embedded HTML forms, Drupal also has to know the michael@529: + * URL on the local/origin server under which Drupal is contacted by the michael@529: + * reverse proxy. This is what $base_url_local is for. michael@529: + * michael@529: + * Examples: michael@529: + * $base_url_local = 'http://www.example.com:8080/drupal'; michael@529: + * michael@529: + * It is not allowed to have a trailing slash; Drupal will add it michael@529: + * for you. michael@529: + */ michael@529: +# $base_url_local = 'http://www.example.com:8080/drupal'; // NO trailing slash! michael@529: + michael@529: +/** michael@529: * PHP settings: michael@529: * michael@529: * To see what PHP settings are possible, including whether they can michael@529: michael@529: ----------------------------------------------------------------------------- michael@529: michael@529: 1. Support HTTP Proxies (mainly for update checks, RSS fetching, etc) michael@529: http://drupal.org/node/7881 michael@529: http://drupal.org/files/issues/proxy_11.patch michael@529: (post-adjusted and improved by RSE) michael@529: michael@529: 2. Fix CSS Cache Building Procedure michael@529: http://drupal.org/node/275381 michael@529: http://drupal.org/files/issues/drupal-css-cache-building.patch michael@529: (created by RSE) michael@529: michael@529: Index: includes/common.inc michael@529: --- includes/common.inc.orig 2008-04-09 23:11:44 +0200 michael@529: +++ includes/common.inc 2008-06-26 20:16:16 +0200 michael@529: @@ -439,13 +439,27 @@ michael@529: case 'http': michael@529: $port = isset($uri['port']) ? $uri['port'] : 80; michael@529: $host = $uri['host'] . ($port != 80 ? ':'. $port : ''); michael@529: - $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15); michael@529: + if (variable_get('proxy_server', '') != '') { michael@529: + $proxy_server = variable_get('proxy_server', ''); michael@529: + $proxy_port = variable_get('proxy_port', 8080); michael@529: + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15); michael@529: + } michael@529: + else { michael@529: + $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15); michael@529: + } michael@529: break; michael@529: case 'https': michael@529: // Note: Only works for PHP 4.3 compiled with OpenSSL. michael@529: $port = isset($uri['port']) ? $uri['port'] : 443; michael@529: $host = $uri['host'] . ($port != 443 ? ':'. $port : ''); michael@529: - $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20); michael@529: + if (variable_get('proxy_server', '') != '') { michael@529: + $proxy_server = variable_get('proxy_server', ''); michael@529: + $proxy_port = variable_get('proxy_port', 8080); michael@529: + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15); michael@529: + } michael@529: + else { michael@529: + $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20); michael@529: + } michael@529: break; michael@529: default: michael@529: $result->error = 'invalid schema '. $uri['scheme']; michael@529: @@ -462,9 +476,14 @@ michael@529: } michael@529: michael@529: // Construct the path to act on. michael@529: - $path = isset($uri['path']) ? $uri['path'] : '/'; michael@529: - if (isset($uri['query'])) { michael@529: - $path .= '?'. $uri['query']; michael@529: + if (variable_get('proxy_server', '') != '') { michael@529: + $path = $url; michael@529: + } michael@529: + else { michael@529: + $path = isset($uri['path']) ? $uri['path'] : '/'; michael@529: + if (isset($uri['query'])) { michael@529: + $path .= '?'. $uri['query']; michael@529: + } michael@529: } michael@529: michael@529: // Create HTTP request. michael@529: @@ -482,6 +501,14 @@ michael@529: $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : '')); michael@529: } michael@529: michael@529: + // If the proxy server required a username then attempt to authenticate with it michael@529: + if (variable_get('proxy_username', '') != '') { michael@529: + $username = variable_get('proxy_username', ''); michael@529: + $password = variable_get('proxy_password', ''); michael@529: + $auth_string = base64_encode($username . ($password != '' ? ':'. $password : '')); michael@529: + $defaults['Proxy-Authorization'] = 'Proxy-Authorization: Basic '. $auth_string ."\r\n"; michael@529: + } michael@529: + michael@529: foreach ($headers as $header => $value) { michael@529: $defaults[$header] = $header .': '. $value; michael@529: } michael@529: Index: modules/system/system.admin.inc michael@529: --- modules/system/system.admin.inc.orig 2008-03-25 12:58:16 +0100 michael@529: +++ modules/system/system.admin.inc 2008-04-24 11:43:07 +0200 michael@529: @@ -1363,6 +1363,65 @@ michael@529: } michael@529: michael@529: /** michael@529: + * Form builder; Configure the site proxy settings. michael@529: + * michael@529: + * @ingroup forms michael@529: + * @see system_settings_form() michael@529: + */ michael@529: +function system_proxy_settings() { michael@529: + michael@529: + $form['forward_proxy'] = array( michael@529: + '#type' => 'fieldset', michael@529: + '#title' => t('Forward proxy settings'), michael@529: + '#description' => t('The proxy server used when Drupal needs to connect to other sites on the Internet.'), michael@529: + ); michael@529: + $form['forward_proxy']['proxy_server'] = array( michael@529: + '#type' => 'textfield', michael@529: + '#title' => t('Proxy host name'), michael@529: + '#default_value' => variable_get('proxy_server', ''), michael@529: + '#description' => t('The host name of the proxy server, eg. localhost. If this is empty Drupal will connect directly to the internet.') michael@529: + ); michael@529: + $form['forward_proxy']['proxy_port'] = array( michael@529: + '#type' => 'textfield', michael@529: + '#title' => t('Proxy port number'), michael@529: + '#default_value' => variable_get('proxy_port', 8080), michael@529: + '#description' => t('The port number of the proxy server, eg. 8080'), michael@529: + ); michael@529: + $form['forward_proxy']['proxy_username'] = array( michael@529: + '#type' => 'textfield', michael@529: + '#title' => t('Proxy username'), michael@529: + '#default_value' => variable_get('proxy_username', ''), michael@529: + '#description' => t('The username used to authenticate with the proxy server.'), michael@529: + ); michael@529: + $form['forward_proxy']['proxy_password'] = array( michael@529: + '#type' => 'textfield', michael@529: + '#title' => t('Proxy password'), michael@529: + '#default_value' => variable_get('proxy_password', ''), michael@529: + '#description' => t('The password used to connect to the proxy server. This is kept as plain text.', '') michael@529: + ); michael@529: + $form['#validate'][] = 'system_proxy_settings_validate'; michael@529: + michael@529: + return system_settings_form($form); michael@529: +} michael@529: + michael@529: +/** michael@529: + * Validate the submitted proxy form. michael@529: + */ michael@529: +function system_proxy_settings_validate($form, &$form_state) { michael@529: + // Validate the proxy settings michael@529: + $form_state['values']['proxy_server'] = trim($form_state['values']['proxy_server']); michael@529: + if ($form_state['values']['proxy_server'] != '') { michael@529: + // TCP allows the port to be between 0 and 65536 inclusive michael@529: + if (!is_numeric($form_state['values']['proxy_port'])) { michael@529: + form_set_error('proxy_port', t('The proxy port is invalid. It must be a number between 0 and 65535.')); michael@529: + } michael@529: + elseif ($form_state['values']['proxy_port'] < 0 || $form_state['values']['proxy_port'] >= 65536) { michael@529: + form_set_error('proxy_port', t('The proxy port is invalid. It must be between 0 and 65535.')); michael@529: + } michael@529: + } michael@529: +} michael@529: + michael@529: +/** michael@529: * Form builder; Configure the site file handling. michael@529: * michael@529: * @ingroup forms michael@529: Index: modules/system/system.module michael@529: --- modules/system/system.module.orig 2008-04-09 23:11:49 +0200 michael@529: +++ modules/system/system.module 2008-04-24 11:43:47 +0200 michael@529: @@ -55,7 +55,7 @@ michael@529: $output .= '
'. t('For more information, see the online handbook entry for System module.', array('@system' => 'http://drupal.org/handbook/modules/system/')) .'
'; michael@529: return $output; michael@529: case 'admin': michael@529: @@ -406,6 +406,14 @@ michael@529: 'access arguments' => array('administer site configuration'), michael@529: 'file' => 'system.admin.inc', michael@529: ); michael@529: + $items['admin/settings/proxy'] = array( michael@529: + 'title' => 'Proxy server', michael@529: + 'description' => 'Configure settings when the site is behind a proxy server.', michael@529: + 'page callback' => 'drupal_get_form', michael@529: + 'page arguments' => array('system_proxy_settings'), michael@529: + 'access arguments' => array('administer site configuration'), michael@529: + 'file' => 'system.admin.inc', michael@529: + ); michael@529: $items['admin/settings/file-system'] = array( michael@529: 'title' => 'File system', michael@529: 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.', michael@529: michael@529: ----------------------------------------------------------------------------- michael@529: michael@529: Disable "Update notifications" check by default during installation. michael@529: michael@529: Index: install.php michael@529: --- install.php.orig 2008-02-08 23:00:45 +0100 michael@529: +++ install.php 2008-05-09 13:18:09 +0200 michael@529: @@ -1069,7 +1069,7 @@ michael@529: '#type' => 'checkboxes', michael@529: '#title' => st('Update notifications'), michael@529: '#options' => array(1 => st('Check for updates automatically')), michael@529: - '#default_value' => array(1), michael@529: + '#default_value' => array(), michael@529: '#description' => st('With this option enabled, Drupal will notify you when new releases are available. This will significantly enhance your site\'s security and is highly recommended. This requires your site to periodically send anonymous information on its installed components to drupal.org. For more information please see the update notification information.', array('@drupal' => 'http://drupal.org', '@update' => 'http://drupal.org/handbook/modules/update')), michael@529: '#weight' => 15, michael@529: ); michael@529: michael@529: ----------------------------------------------------------------------------- michael@529: michael@529: No need to always expand the "Menu settings" on node edit pages. michael@529: michael@529: Index: modules/menu/menu.module michael@529: --- modules/menu/menu.module.orig 2008-04-09 23:11:48 +0200 michael@529: +++ modules/menu/menu.module 2008-05-16 20:03:48 +0200 michael@529: @@ -366,7 +366,7 @@ michael@529: '#title' => t('Menu settings'), michael@529: '#access' => user_access('administer menu'), michael@529: '#collapsible' => TRUE, michael@529: - '#collapsed' => FALSE, michael@529: + '#collapsed' => TRUE, michael@529: '#tree' => TRUE, michael@529: '#weight' => -2, michael@529: '#attributes' => array('class' => 'menu-item-form'), michael@529: michael@529: ----------------------------------------------------------------------------- michael@529: michael@529: Use a larger text-area on node edit pages. michael@529: michael@529: Index: modules/node/node.pages.inc michael@529: --- modules/node/node.pages.inc.orig 2008-02-27 20:44:44 +0100 michael@529: +++ modules/node/node.pages.inc 2008-05-16 20:06:45 +0200 michael@529: @@ -287,7 +287,8 @@ michael@529: '#type' => 'textarea', michael@529: '#title' => check_plain($label), michael@529: '#default_value' => $include ? $node->body : ($node->teaser . $node->body), michael@529: - '#rows' => 20, michael@529: + '#rows' => 30, michael@529: + '#cols' => 80, michael@529: '#required' => ($word_count > 0), michael@529: ); michael@529: michael@529: ----------------------------------------------------------------------------- michael@529: michael@529: Avoid incorrect ordering of BLOG entries by removing the michael@529: db_rewrite_sql() calls which seem to introduce a wrong ordering. michael@529: michael@529: Index: modules/blog/blog.module michael@529: --- modules/blog/blog.module.orig 2008-05-19 09:27:35 +0200 michael@529: +++ modules/blog/blog.module 2008-07-29 21:20:42 +0200 michael@529: @@ -182,13 +182,13 @@ michael@529: * Helper function to determine if a user has blog posts already. michael@529: */ michael@529: function _blog_post_exists($account) { michael@529: - return (bool)db_result(db_query_range(db_rewrite_sql("SELECT 1 FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1"), $account->uid, 0, 1)); michael@529: + return (bool)db_result(db_query_range("SELECT 1 FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1", $account->uid, 0, 1)); michael@529: } michael@529: michael@529: /** michael@529: * Implementation of hook_block(). michael@529: * michael@529: - * Displays the most recent 10 blog titles. michael@529: + * Displays the most recent 5 blog titles. michael@529: */ michael@529: function blog_block($op = 'list', $delta = 0) { michael@529: global $user; michael@529: @@ -198,7 +198,7 @@ michael@529: } michael@529: else if ($op == 'view') { michael@529: if (user_access('access content')) { michael@529: - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10); michael@529: + $result = db_query_range("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC", 0, 5); michael@529: if ($node_title_list = node_title_list($result)) { michael@529: $block['content'] = $node_title_list; michael@529: $block['content'] .= theme('more_link', url('blog'), t('Read the latest blog entries.')); michael@529: Index: modules/blog/blog.pages.inc michael@529: --- modules/blog/blog.pages.inc.orig 2009-09-14 17:08:00 +0200 michael@529: +++ modules/blog/blog.pages.inc 2009-09-19 08:53:18 +0200 michael@529: @@ -25,7 +25,7 @@ michael@529: michael@529: $output = theme('item_list', $items); michael@529: michael@529: - $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid); michael@529: + $result = pager_query("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC", variable_get('default_nodes_main', 10), 0, NULL, $account->uid); michael@529: $has_posts = FALSE; michael@529: michael@529: while ($node = db_fetch_object($result)) { michael@529: @@ -64,7 +64,7 @@ michael@529: michael@529: $output = theme('item_list', $items); michael@529: michael@529: - $result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10)); michael@529: + $result = pager_query("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC", variable_get('default_nodes_main', 10)); michael@529: $has_posts = FALSE; michael@529: michael@529: while ($node = db_fetch_object($result)) { michael@529: @@ -87,7 +87,7 @@ michael@529: * Menu callback; displays an RSS feed containing recent blog entries of a given user. michael@529: */ michael@529: function blog_feed_user($account) { michael@529: - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $account->uid, 0, variable_get('feed_default_items', 10)); michael@529: + $result = db_query_range("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC", $account->uid, 0, variable_get('feed_default_items', 10)); michael@529: $channel['title'] = t("!name's blog", array('!name' => $account->name)); michael@529: $channel['link'] = url('blog/'. $account->uid, array('absolute' => TRUE)); michael@529: michael@529: @@ -102,7 +102,7 @@ michael@529: * Menu callback; displays an RSS feed containing recent blog entries of all users. michael@529: */ michael@529: function blog_feed_last() { michael@529: - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10)); michael@529: + $result = db_query_range("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC", 0, variable_get('feed_default_items', 10)); michael@529: $channel['title'] = t('!site_name blogs', array('!site_name' => variable_get('site_name', 'Drupal'))); michael@529: $channel['link'] = url('blog', array('absolute' => TRUE)); michael@529: