diff -Naur drupal-5.0/.htaccess drupal-5.23/.htaccess
--- drupal-5.0/.htaccess	2007-01-09 10:27:10.000000000 +0100
+++ drupal-5.23/.htaccess	2009-02-26 08:03:29.000000000 +0100
@@ -3,7 +3,7 @@
 #
 
 # Protect files and directories from prying eyes.
-<FilesMatch "(\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
+<FilesMatch "\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
   Order allow,deny
 </FilesMatch>
 
@@ -13,9 +13,14 @@
 # Follow symbolic links in this directory.
 Options +FollowSymLinks
 
-# Customized error messages.
+# Make Drupal handle any 404 errors.
 ErrorDocument 404 /index.php
 
+# Force simple error message for requests for non-existent favicon.ico.
+<Files favicon.ico>
+  ErrorDocument 404 "The requested file favicon.ico was not found.
+</Files>
+
 # Set the default handler.
 DirectoryIndex index.php
 
@@ -27,6 +32,9 @@
   php_value magic_quotes_gpc                0
   php_value register_globals                0
   php_value session.auto_start              0
+  php_value mbstring.http_input             pass
+  php_value mbstring.http_output            pass
+  php_value mbstring.encoding_translation   0
 </IfModule>
 
 # PHP 4, Apache 2.
@@ -34,6 +42,9 @@
   php_value magic_quotes_gpc                0
   php_value register_globals                0
   php_value session.auto_start              0
+  php_value mbstring.http_input             pass
+  php_value mbstring.http_output            pass
+  php_value mbstring.encoding_translation   0
 </IfModule>
 
 # PHP 5, Apache 1 and 2.
@@ -41,6 +52,9 @@
   php_value magic_quotes_gpc                0
   php_value register_globals                0
   php_value session.auto_start              0
+  php_value mbstring.http_input             pass
+  php_value mbstring.http_output            pass
+  php_value mbstring.encoding_translation   0
 </IfModule>
 
 # Requires mod_expires to be enabled.
@@ -57,22 +71,31 @@
 <IfModule mod_rewrite.c>
   RewriteEngine on
 
-  # If your site can be accessed both with and without the prefix www. you
-  # can use one of the following settings to force user to use only one option:
+  # If your site can be accessed both with and without the 'www.' prefix, you
+  # can use one of the following settings to redirect users to your preferred
+  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
   #
-  # If you want the site to be accessed WITH the www. only, adapt and
-  # uncomment the following:
+  # To redirect all users to access the site WITH the 'www.' prefix,
+  # (http://example.com/... will be redirected to http://www.example.com/...)
+  # adapt and uncomment the following:
   # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
-  # RewriteRule .* http://www.example.com/ [L,R=301]
+  # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
   #
-  # If you want the site to be accessed only WITHOUT the www. prefix, adapt
-  # and uncomment the following:
+  # To redirect all users to access the site WITHOUT the 'www.' prefix,
+  # (http://www.example.com/... will be redirected to http://example.com/...)
+  # uncomment and adapt the following:
   # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
-  # RewriteRule .* http://example.com/ [L,R=301]
+  # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
 
-  # Modify the RewriteBase if you are using Drupal in a subdirectory and
-  # the rewrite rules are not working properly.
-  #RewriteBase /drupal
+  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
+  # VirtualDocumentRoot and the rewrite rules are not working properly.
+  # For example if your site is at http://example.com/drupal uncomment and
+  # modify the following line:
+  # RewriteBase /drupal
+  #
+  # If your site is running in a VirtualDocumentRoot at http://example.com/,
+  # uncomment the following line:
+  # RewriteBase /
 
   # Rewrite old-style URLs of the form 'node.php?id=x'.
   #RewriteCond %{REQUEST_FILENAME} !-f
@@ -86,10 +109,11 @@
   #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
   #RewriteRule module.php index.php?q=%1 [L]
 
-  # Rewrite current-style URLs of the form 'index.php?q=x'.
+  # Rewrite current-style URLs of the form 'x' to the form 'index.php?q=x'.
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
+  RewriteCond %{REQUEST_URI} !=/favicon.ico
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
 </IfModule>
 
-# $Id: .htaccess,v 1.81 2007/01/09 09:27:10 dries Exp $
+# $Id: .htaccess,v 1.81.2.6 2009/02/26 07:03:29 drumm Exp $
diff -Naur drupal-5.0/CHANGELOG.txt drupal-5.23/CHANGELOG.txt
--- drupal-5.0/CHANGELOG.txt	2007-01-15 13:11:23.000000000 +0100
+++ drupal-5.23/CHANGELOG.txt	2010-08-11 22:37:49.000000000 +0200
@@ -1,4 +1,136 @@
-// $Id: CHANGELOG.txt,v 1.173.2.1 2007/01/15 12:11:23 unconed Exp $
+// $Id: CHANGELOG.txt,v 1.173.2.50 2010/08/11 20:37:49 drumm Exp $
+
+Drupal 5.23, 2010-08-11
+-----------------------
+- Fixed security issues (File download access bypass, Comment unpublishing
+  bypass), see SA-CORE-2010-002.
+
+Drupal 5.22, 2010-03-03
+-----------------------
+- Fixed security issues (Open redirection, Locale module cross site scripting,
+  Blocked user session regeneration), see SA-CORE-2010-001.
+
+Drupal 5.21, 2009-12-16
+-----------------------
+- Fixed a security issue (Cross site scripting), see SA-CORE-2009-009.
+- Fixed a variety of small bugs.
+
+Drupal 5.20, 2009-09-16
+-----------------------
+- Avoid security problems resulting from writing Drupal 6-style menu
+  declarations.
+- Fixed security issues (session fixation), see SA-CORE-2009-008.
+- Fixed a variety of small bugs.
+
+Drupal 5.19, 2009-07-01
+-----------------------
+- Fixed security issues (Cross site scripting and Password leakage in URL), see
+  SA-CORE-2009-007.          
+- Fixed a variety of small bugs.
+
+Drupal 5.18, 2009-05-13
+-----------------------
+- Fixed security issues (Cross site scripting), see SA-CORE-2009-006.
+- Fixed a variety of small bugs.
+
+Drupal 5.17, 2009-04-29
+-----------------------
+- Fixed security issues (Cross site scripting and limited information
+  disclosure) see SA-CORE-2009-005.
+- Fixed a variety of small bugs.
+
+Drupal 5.16, 2009-02-25
+-----------------------
+- Fixed a security issue, (Local file inclusion on Windows), see SA-CORE-2009-004.
+- Fixed a variety of small bugs.
+
+Drupal 5.15, 2009-01-14
+-----------------------
+- Fixed security issues, (Hardening against SQL injection), see
+  SA-CORE-2009-001
+- Fixed HTTP_HOST checking to work again with HTTP 1.0 clients and basic shell
+  scripts.
+- Fixed a variety of small bugs.
+
+Drupal 5.14, 2008-12-11
+-----------------------
+- removed a previous change incompatible with PHP 5.1.x and lower.
+
+Drupal 5.13, 2008-12-10
+-----------------------
+- fixed a variety of small bugs.
+- fixed security issues, (Cross site request forgery and Cross site scripting), see SA-2008-073
+- updated robots.txt and .htaccess to match current file use.
+
+Drupal 5.12, 2008-10-22
+-----------------------
+- fixed security issues, (File inclusion), see SA-2008-067
+
+Drupal 5.11, 2008-10-08
+-----------------------
+- fixed a variety of small bugs.
+- fixed security issues, (File upload access bypass, Access rules bypass,
+  BlogAPI access bypass, Node validation bypass), see SA-2008-060
+
+Drupal 5.10, 2008-08-13
+-----------------------
+- fixed a variety of small bugs.
+- fixed security issues, (Cross site scripting, Arbitrary file uploads via
+  BlogAPI and Cross site request forgery), see SA-2008-047
+
+Drupal 5.9, 2008-07-23
+----------------------
+- fixed a variety of small bugs.
+- fixed security issues, (Session fixation), see SA-2008-046
+
+Drupal 5.8, 2008-07-09
+----------------------
+- fixed a variety of small bugs.
+- fixed security issues, (Cross site scripting, cross site request forgery, and
+  session fixation), see SA-2008-044
+
+Drupal 5.7, 2008-01-28
+----------------------
+- fixed the input format configuration page.
+- fixed a variety of small bugs.
+
+Drupal 5.6, 2008-01-10
+----------------------
+- fixed a variety of small bugs.
+- fixed a security issue (Cross site request forgery), see SA-2008-005
+- fixed a security issue (Cross site scripting, UTF8), see SA-2008-006
+- fixed a security issue (Cross site scripting, register_globals), see SA-2008-007
+
+Drupal 5.5, 2007-12-06
+----------------------
+- fixed missing missing brackets in a query in the user module.
+- fixed taxonomy feed bug introduced by SA-2007-031
+
+Drupal 5.4, 2007-12-05
+----------------------
+- fixed a variety of small bugs.
+- fixed a security issue (SQL injection), see SA-2007-031
+
+Drupal 5.3, 2007-10-17
+----------------------
+- fixed a variety of small bugs.
+- fixed a security issue (HTTP response splitting), see SA-2007-024
+- fixed a security issue (Arbitrary code execution via installer), see SA-2007-025
+- fixed a security issue (Cross site scripting via uploads), see SA-2007-026
+- fixed a security issue (User deletion cross site request forgery), see SA-2007-029
+- fixed a security issue (API handling of unpublished comment), see SA-2007-030
+
+Drupal 5.2, 2007-07-26
+----------------------
+- changed hook_link() $teaser argument to match documentation.
+- fixed a variety of small bugs.
+- fixed a security issue (cross-site request forgery), see SA-2007-017
+- fixed a security issue (cross-site scripting), see SA-2007-018
+
+Drupal 5.1, 2007-01-29
+----------------------
+- fixed security issue (code execution), see SA-2007-005
+- fixed a variety of small bugs.
 
 Drupal 5.0, 2007-01-15
 ------------------------
@@ -77,6 +209,61 @@
     * added nested lists generation.
     * added a self-clearing block class.
 
+Drupal 4.7.11, 2008-01-10
+-------------------------
+- fixed a security issue (Cross site request forgery), see SA-2008-005
+- fixed a security issue (Cross site scripting, UTF8), see SA-2008-006
+- fixed a security issue (Cross site scripting, register_globals), see SA-2008-007
+
+Drupal 4.7.10, 2007-12-06
+-------------------------
+- fixed taxonomy feed bug introduced by SA-2007-031
+
+Drupal 4.7.9, 2007-12-05
+------------------------
+- fixed a security issue (SQL injection), see SA-2007-031
+
+Drupal 4.7.8, 2007-10-17
+------------------------
+- fixed a security issue (HTTP response splitting), see SA-2007-024
+- fixed a security issue (Cross site scripting via uploads), see SA-2007-026
+- fixed a security issue (API handling of unpublished comment), see SA-2007-030
+
+Drupal 4.7.7, 2007-07-26
+------------------------
+- fixed security issue (XSS), see SA-2007-018
+
+Drupal 4.7.6, 2007-01-29
+------------------------
+- fixed security issue (code execution), see SA-2007-005
+
+Drupal 4.7.5, 2007-01-05
+------------------------
+- fixed security issue (XSS), see SA-2007-001
+- fixed security issue (DoS), see SA-2007-002
+
+Drupal 4.7.4, 2006-10-18
+------------------------
+- fixed security issue (XSS), see SA-2006-024
+- fixed security issue (CSRF), see SA-2006-025
+- fixed security issue (Form action attribute injection), see SA-2006-026
+
+Drupal 4.7.3, 2006-08-02
+------------------------
+- fixed security issue (XSS), see SA-2006-011
+
+Drupal 4.7.2, 2006-06-01
+------------------------
+- fixed critical upload issue, see SA-2006-007
+- fixed taxonomy XSS issue, see SA-2006-008
+- fixed a variety of small bugs.
+
+Drupal 4.7.1, 2006-05-24
+------------------------
+- fixed critical SQL issue, see SA-2006-005
+- fixed a serious upgrade related bug.
+- fixed a variety of small bugs.
+
 Drupal 4.7.0, 2006-05-01
 ------------------------
 - added free tagging support.
@@ -144,6 +331,30 @@
     * added support for a tolerant Base URL.
     * output URIs relative to the root, without a base tag.
 
+Drupal 4.6.11, 2007-01-05
+-------------------------
+- fixed security issue (XSS), see SA-2007-001
+- fixed security issue (DoS), see SA-2007-002
+
+Drupal 4.6.10, 2006-10-18
+------------------------
+- fixed security issue (XSS), see SA-2006-024
+- fixed security issue (CSRF), see SA-2006-025
+- fixed security issue (Form action attribute injection), see SA-2006-026
+
+Drupal 4.6.9, 2006-08-02
+------------------------
+- fixed security issue (XSS), see SA-2006-011
+
+Drupal 4.6.8, 2006-06-01
+------------------------
+- fixed critical upload issue, see SA-2006-007
+- fixed taxonomy XSS issue, see SA-2006-008
+
+Drupal 4.6.7, 2006-05-24
+------------------------
+- fixed critical SQL issue, see SA-2006-005
+
 Drupal 4.6.6, 2006-03-13
 ------------------------
 - fixed bugs, including 4 security vulnerabilities.
diff -Naur drupal-5.0/INSTALL.txt drupal-5.23/INSTALL.txt
--- drupal-5.0/INSTALL.txt	2007-01-08 12:59:16.000000000 +0100
+++ drupal-5.23/INSTALL.txt	2008-01-10 23:14:24.000000000 +0100
@@ -1,4 +1,4 @@
-// $Id: INSTALL.txt,v 1.39 2007/01/08 11:59:16 dries Exp $
+// $Id: INSTALL.txt,v 1.39.2.3 2008/01/10 22:14:24 drumm Exp $
 
 CONTENTS OF THIS FILE
 ---------------------
@@ -22,7 +22,7 @@
 REQUIREMENTS
 ------------
 
-Drupal requires a web server, PHP4 (4.3.3 or greater) or PHP5
+Drupal requires a web server, PHP4 (4.3.5 or greater) or PHP5
 (http://www.php.net/) and either MySQL (http://www.mysql.com/) or PostgreSQL
 (http://www.postgresql.org/). The Apache web server and MySQL database are
 recommended; other web server and database combinations such as IIS and
@@ -120,7 +120,7 @@
    following example crontab line will activate the cron tasks automatically on
    the hour:
 
-   0   *   *   *   *   wget -O - -q http://www.example.com/cron.php
+   0   *   *   *   *   wget -O - -q -t 1 http://www.example.com/cron.php
 
    More information about the cron scripts are available in the admin help pages
    and in the Drupal handbook at drupal.org. Example scripts can be found in the
@@ -134,10 +134,10 @@
 
 Use your administration panel to enable and configure services. For example:
 
-General Settings       administer > site configuration > site information
-Enable Modules         administer > site configuration > modules
-Set User Permissions   administer > users management > access control
-Configure Themes       administer > site building > themes
+General Settings       Administer > Site configuration > Site information
+Enable Modules         Administer > Site building > Modules
+Set User Permissions   Administer > User management > Access control
+Configure Themes       Administer > Site building > Themes
 
 For more information on configuration options, read the instructions which
 accompany the different configuration settings and consult the various help
diff -Naur drupal-5.0/LICENSE.txt drupal-5.23/LICENSE.txt
--- drupal-5.0/LICENSE.txt	2006-07-09 13:33:06.000000000 +0200
+++ drupal-5.23/LICENSE.txt	2009-01-14 06:56:37.000000000 +0100
@@ -1,14 +1,13 @@
-// $Id: LICENSE.txt,v 1.5 2006/07/09 11:33:06 dries Exp $
+// $Id: LICENSE.txt,v 1.5.2.1 2009/01/14 05:56:37 drumm Exp $
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
 
-        GNU GENERAL PUBLIC LICENSE
-           Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
-          Preamble
+			    Preamble
 
   The licenses for most software are designed to take away your
 freedom to share and change it.  By contrast, the GNU General Public
@@ -58,7 +57,7 @@
   The precise terms and conditions for copying, distribution and
 modification follow.
 
-        GNU GENERAL PUBLIC LICENSE
+		    GNU GENERAL PUBLIC LICENSE
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
   0. This License applies to any program or other work which contains
@@ -257,7 +256,7 @@
 of preserving the free status of all derivatives of our free software and
 of promoting the sharing and reuse of software generally.
 
-          NO WARRANTY
+			    NO WARRANTY
 
   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
@@ -279,9 +278,9 @@
 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGES.
 
-         END OF TERMS AND CONDITIONS
+		     END OF TERMS AND CONDITIONS
 
-      How to Apply These Terms to Your New Programs
+	    How to Apply These Terms to Your New Programs
 
   If you develop a new program, and you want it to be of the greatest
 possible use to the public, the best way to achieve this is to make it
@@ -305,10 +304,9 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 Also add information on how to contact you by electronic and paper mail.
 
diff -Naur drupal-5.0/includes/bootstrap.inc drupal-5.23/includes/bootstrap.inc
--- drupal-5.0/includes/bootstrap.inc	2007-01-15 12:52:02.000000000 +0100
+++ drupal-5.23/includes/bootstrap.inc	2009-04-30 02:13:48.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: bootstrap.inc,v 1.145 2007/01/15 11:52:02 unconed Exp $
+// $Id: bootstrap.inc,v 1.145.2.14 2009/04/30 00:13:48 drumm Exp $
 
 /**
  * @file
@@ -200,7 +200,7 @@
   }
 
   $confdir = 'sites';
-  $uri = explode('/', $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']);
+  $uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);
   $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
   for ($i = count($uri) - 1; $i > 0; $i--) {
     for ($j = count($server); $j > 0; $j--) {
@@ -230,11 +230,47 @@
 }
 
 /**
- * Loads the configuration and sets the base URL correctly.
+ * Validate that a hostname (for example $_SERVER['HTTP_HOST']) is safe.
+ *
+ * As $_SERVER['HTTP_HOST'] is user input, ensure it only contains characters
+ * allowed in hostnames.  See RFC 952 (and RFC 2181). $_SERVER['HTTP_HOST'] is
+ * lowercased.
+ *
+ * @return
+ *  TRUE if only containing valid characters, or FALSE otherwise.
+ */
+function drupal_valid_http_host($host) {
+  return preg_match('/^\[?(?:[a-z0-9-:\]_]+\.?)+$/', $host);
+}
+
+/**
+ * Loads the configuration and sets the base URL, cookie domain, and
+ * session name correctly.
  */
 function conf_init() {
-  global $db_url, $db_prefix, $base_url, $base_path, $base_root, $conf, $installed_profile;
+  global $base_url, $base_path, $base_root;
+
+  // Export the following settings.php variables to the global namespace
+  global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile;
   $conf = array();
+
+  if (isset($_SERVER['HTTP_HOST'])) {
+    // As HTTP_HOST is user input, ensure it only contains characters allowed
+    // in hostnames. See RFC 952 (and RFC 2181).
+    // $_SERVER['HTTP_HOST'] is lowercased here per specifications.
+    $_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']);
+    if (!drupal_valid_http_host($_SERVER['HTTP_HOST'])) {
+      // HTTP_HOST is invalid, e.g. if containing slashes it may be an attack.
+      header('HTTP/1.1 400 Bad Request');
+      exit;
+    }
+  }
+  else {
+    // Some pre-HTTP/1.1 clients will not send a Host header. Ensure the key is
+    // defined for E_ALL compliance.
+    $_SERVER['HTTP_HOST'] = '';
+  }
+
   include_once './'. conf_path() .'/settings.php';
 
   if (isset($base_url)) {
@@ -250,8 +286,12 @@
   else {
     // Create base URL
     $base_root = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
+
     $base_url = $base_root .= '://'. $_SERVER['HTTP_HOST'];
-    if ($dir = trim(dirname($_SERVER['PHP_SELF']), '\,/')) {
+
+    // $_SERVER['SCRIPT_NAME'] can, in contrast to $_SERVER['PHP_SELF'], not
+    // be modified by a visitor.
+    if ($dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/')) {
       $base_path = "/$dir";
       $base_url .= $base_path;
       $base_path .= '/';
@@ -260,6 +300,47 @@
       $base_path = '/';
     }
   }
+
+  if (!$cookie_domain) {
+    // If the $cookie_domain is empty, try to use the session.cookie_domain.
+    $cookie_domain = ini_get('session.cookie_domain');
+  }
+  if ($cookie_domain) {
+    // If the user specifies the cookie domain, also use it for session name.
+    $session_name = $cookie_domain;
+  }
+  else {
+    // Otherwise use $base_url as session name, without the protocol
+    // to use the same session identifiers across http and https.
+    list( , $session_name) = explode('://', $base_url, 2);
+    // We try to set the cookie domain to the hostname.
+    // We escape the hostname because it can be modified by a visitor.
+    if (!empty($_SERVER['HTTP_HOST'])) {
+      $cookie_domain = check_plain($_SERVER['HTTP_HOST']);
+    }
+  }
+  // To prevent session cookies from being hijacked, a user can configure the
+  // SSL version of their website to only transfer session cookies via SSL by
+  // using PHP's session.cookie_secure setting. The browser will then use two
+  // separate session cookies for the HTTPS and HTTP versions of the site. So we
+  // must use different session identifiers for HTTPS and HTTP to prevent a
+  // cookie collision.
+  if (ini_get('session.cookie_secure')) {
+    $session_name .= 'SSL';
+  }
+  // Strip leading periods, www., and port numbers from cookie domain.
+  $cookie_domain = ltrim($cookie_domain, '.');
+  if (strpos($cookie_domain, 'www.') === 0) {
+    $cookie_domain = substr($cookie_domain, 4);
+  }
+  $cookie_domain = explode(':', $cookie_domain);
+  $cookie_domain = '.'. $cookie_domain[0];
+  // Per RFC 2109, cookie domains must contain at least one dot other than the
+  // first. For hosts such as 'localhost' or IP Addresses we don't set a cookie domain.
+  if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
+    ini_set('session.cookie_domain', $cookie_domain);
+  }
+  session_name('SESS'. md5($session_name));
 }
 
 /**
@@ -487,7 +568,7 @@
 function drupal_page_header() {
   header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
-  header("Cache-Control: no-store, no-cache, must-revalidate");
+  header("Cache-Control: store, no-cache, must-revalidate");
   header("Cache-Control: post-check=0, pre-check=0", FALSE);
 }
 
@@ -515,7 +596,7 @@
     header('HTTP/1.1 304 Not Modified');
     // All 304 responses must send an etag if the 200 response for the same object contained an etag
     header("Etag: $etag");
-    exit();
+    return;
   }
 
   // Send appropriate response:
@@ -583,9 +664,48 @@
 
 /**
  * Encode special characters in a plain-text string for display as HTML.
+ *
+ * Uses drupal_validate_utf8 to prevent cross site scripting attacks on
+ * Internet Explorer 6.
  */
 function check_plain($text) {
-  return htmlspecialchars($text, ENT_QUOTES);
+  return drupal_validate_utf8($text) ? htmlspecialchars($text, ENT_QUOTES) : '';
+}
+
+/**
+ * Checks whether a string is valid UTF-8.
+ *
+ * All functions designed to filter input should use drupal_validate_utf8
+ * to ensure they operate on valid UTF-8 strings to prevent bypass of the
+ * filter.
+ *
+ * When text containing an invalid UTF-8 lead byte (0xC0 - 0xFF) is presented
+ * as UTF-8 to Internet Explorer 6, the program may misinterpret subsequent
+ * bytes. When these subsequent bytes are HTML control characters such as
+ * quotes or angle brackets, parts of the text that were deemed safe by filters
+ * end up in locations that are potentially unsafe; An onerror attribute that
+ * is outside of a tag, and thus deemed safe by a filter, can be interpreted
+ * by the browser as if it were inside the tag.
+ *
+ * This function exploits preg_match behaviour (since PHP 4.3.5) when used
+ * with the u modifier, as a fast way to find invalid UTF-8. When the matched
+ * string contains an invalid byte sequence, it will fail silently.
+ *
+ * preg_match may not fail on 4 and 5 octet sequences, even though they
+ * are not supported by the specification.
+ *
+ * The specific preg_match behaviour is present since PHP 4.3.5.
+ *
+ * @param $text
+ *   The text to check.
+ * @return
+ *   TRUE if the text is valid UTF-8, FALSE if not.
+ */
+function drupal_validate_utf8($text) {
+  if (strlen($text) == 0) {
+    return TRUE;
+  }
+  return (preg_match('/^./us', $text) == 1);
 }
 
 /**
@@ -599,12 +719,14 @@
   }
   else {
     if (isset($_SERVER['argv'])) {
-      $uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['argv'][0];
+      $uri = $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['argv'][0];
     }
     else {
-      $uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
+      $uri = $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['QUERY_STRING'];
     }
   }
+  // Prevent multiple slashes to avoid cross site requests via the FAPI.
+  $uri = '/'. ltrim($uri, '/');
 
   return $uri;
 }
@@ -677,6 +799,11 @@
  *   (optional) Only return messages of this type.
  * @param $clear_queue
  *   (optional) Set to FALSE if you do not want to clear the messages queue
+ * @return
+ *   An associative array, the key is the message type, the value an array
+ *   of messages. If the $type parameter is passed, you get only that type,
+ *   or an empty array if there are no such messages. If $type is not passed,
+ *   all message types are returned, or an empty array if none exist.
  */
 function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
   if ($messages = drupal_set_message()) {
@@ -684,7 +811,9 @@
       if ($clear_queue) {
          unset($_SESSION['messages'][$type]);
       }
-      return array($type => $messages[$type]);
+      if (isset($messages[$type])) {
+        return array($type => $messages[$type]);
+      }
     }
     else {
       if ($clear_queue) {
@@ -742,6 +871,7 @@
   $user->roles = array();
   $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
   $user->session = $session;
+  $user->cache = 0;
   return $user;
 }
 
@@ -767,11 +897,9 @@
 function drupal_bootstrap($phase) {
   static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL);
 
-  while (!is_null($current_phase = array_shift($phases))) {
+  while (!empty($phases) && $phase >= $phases[0]) {
+    $current_phase = array_shift($phases);
     _drupal_bootstrap($current_phase);
-    if ($phase == $current_phase) {
-      return;
-    }
   }
 }
 
diff -Naur drupal-5.0/includes/cache.inc drupal-5.23/includes/cache.inc
--- drupal-5.0/includes/cache.inc	2006-11-10 08:26:27.000000000 +0100
+++ drupal-5.23/includes/cache.inc	2009-07-10 07:41:24.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: cache.inc,v 1.5 2006/11/10 07:26:27 drumm Exp $
+// $Id: cache.inc,v 1.5.2.6 2009/07/10 05:41:24 drumm Exp $
 
 /**
  * Return data from the persistent cache.
@@ -14,14 +14,15 @@
   global $user;
 
   // Garbage collection necessary when enforcing a minimum cache lifetime
-  $cache_flush = variable_get('cache_flush', 0);
+  $cache_flush = variable_get('cache_flush_'. $table, 0);
   if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= time())) {
+    // Reset the variable immediately to prevent a meltdown in heavy load situations.
+    variable_set('cache_flush_'. $table, 0);
     // Time to flush old cache data
-    db_query("DELETE FROM {%s} WHERE expire != %d AND expire <= %d", $table, CACHE_PERMANENT, $cache_flush);
-    variable_set('cache_flush', 0);
+    db_query("DELETE FROM {". $table ."} WHERE expire != %d AND expire <= %d", CACHE_PERMANENT, $cache_flush);
   }
 
-  $cache = db_fetch_object(db_query("SELECT data, created, headers, expire FROM {%s} WHERE cid = '%s'", $table, $key));
+  $cache = db_fetch_object(db_query("SELECT data, created, headers, expire FROM {". $table ."} WHERE cid = '%s'", $key));
   if (isset($cache->data)) {
     // If the data is permanent or we're not enforcing a minimum cache lifetime
     // always return the cached data.
@@ -92,9 +93,9 @@
  */
 function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
   db_lock_table($table);
-  db_query("UPDATE {%s} SET data = %b, created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $table, $data, time(), $expire, $headers, $cid);
+  db_query("UPDATE {". $table. "} SET data = %b, created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, time(), $expire, $headers, $cid);
   if (!db_affected_rows()) {
-    @db_query("INSERT INTO {%s} (cid, data, created, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $table, $cid, $data, time(), $expire, $headers);
+    @db_query("INSERT INTO {". $table. "} (cid, data, created, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $cid, $data, time(), $expire, $headers);
   }
   db_unlock_tables();
 }
@@ -133,34 +134,34 @@
       // cached data that was cached before the timestamp.
       $user->cache = time();
 
-      $cache_flush = variable_get('cache_flush', 0);
+      $cache_flush = variable_get('cache_flush_'. $table, 0);
       if ($cache_flush == 0) {
         // This is the first request to clear the cache, start a timer.
-        variable_set('cache_flush', time());
+        variable_set('cache_flush_'. $table, time());
       }
       else if (time() > ($cache_flush + variable_get('cache_lifetime', 0))) {
-        // Clear the cache for everyone, cache_flush_delay seconds have
+        // Clear the cache for everyone, cache_lifetime seconds have
         // passed since the first request to clear the cache.
-        db_query("DELETE FROM {%s} WHERE expire != %d AND expire < %d", $table, CACHE_PERMANENT, time());
-        variable_set('cache_flush', 0);
+        db_query("DELETE FROM {". $table. "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
+        variable_set('cache_flush_'. $table, 0);
       }
     }
     else {
       // No minimum cache lifetime, flush all temporary cache entries now.
-      db_query("DELETE FROM {%s} WHERE expire != %d AND expire < %d", $table, CACHE_PERMANENT, time());
+      db_query("DELETE FROM {". $table. "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
     }
   }
   else {
     if ($wildcard) {
       if ($cid == '*') {
-        db_query("TRUNCATE TABLE {%s}", $table);
+        db_query("DELETE FROM {". $table. "}");
       }
       else {
-        db_query("DELETE FROM {%s} WHERE cid LIKE '%s%%'", $table, $cid);
+        db_query("DELETE FROM {". $table. "} WHERE cid LIKE '%s%%'", $cid);
       }
     }
     else {
-      db_query("DELETE FROM {%s} WHERE cid = '%s'", $table, $cid);
+      db_query("DELETE FROM {". $table. "} WHERE cid = '%s'", $cid);
     }
   }
 }
diff -Naur drupal-5.0/includes/common.inc drupal-5.23/includes/common.inc
--- drupal-5.0/includes/common.inc	2007-01-11 00:30:07.000000000 +0100
+++ drupal-5.23/includes/common.inc	2010-03-04 01:16:02.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: common.inc,v 1.611 2007/01/10 23:30:07 unconed Exp $
+// $Id: common.inc,v 1.611.2.26 2010/03/04 00:16:02 drumm Exp $
 
 /**
  * @file
@@ -152,6 +152,15 @@
 }
 
 /**
+ * Make any final alterations to the rendered xhtml.
+ */
+function drupal_final_markup($content) {
+  // Make sure that the charset is always specified as the first element of the
+  // head region to prevent encoding-based attacks.
+  return preg_replace('/<head[^>]*>/i', "\$0\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />", $content, 1);
+}
+
+/**
  * Add a feed URL for the current page.
  *
  * @param $url
@@ -197,8 +206,6 @@
  *   The array to be processed e.g. $_GET
  * @param $exclude
  *   The array filled with keys to be excluded. Use parent[child] to exclude nested items.
- * @param $urlencode
- *   If TRUE, the keys and values are both urlencoded.
  * @param $parent
  *   Should not be passed, only used in recursive calls
  * @return
@@ -269,9 +276,8 @@
  * 'user login'-block in a sidebar. The function drupal_get_destination()
  * can be used to help set the destination URL.
  *
- * It is advised to use drupal_goto() instead of PHP's header(), because
- * drupal_goto() will append the user's session ID to the URI when PHP is
- * compiled with "--enable-trans-sid".
+ * Drupal will ensure that messages set by drupal_set_message() and other
+ * session data are written to the database before the user is redirected.
  *
  * This function ends the request; use it rather than a print theme('page')
  * statement in your menu callback.
@@ -296,18 +302,35 @@
  * @see drupal_get_destination()
  */
 function drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response_code = 302) {
+
+  $destination = FALSE;
   if (isset($_REQUEST['destination'])) {
-    extract(parse_url(urldecode($_REQUEST['destination'])));
+    $destination = $_REQUEST['destination'];
   }
   else if (isset($_REQUEST['edit']['destination'])) {
-    extract(parse_url(urldecode($_REQUEST['edit']['destination'])));
+    $destination = $_REQUEST['edit']['destination'];
+  }
+
+  if ($destination) {
+    // Do not redirect to an absolute URL originating from user input.
+    $colonpos = strpos($destination, ':');
+    $absolute = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($destination, 0, $colonpos)));
+    if (!$absolute) {
+      extract(parse_url(urldecode($destination)));
+    }
   }
 
   $url = url($path, $query, $fragment, TRUE);
+  // Remove newlines from the URL to avoid header injection attacks.
+  $url = str_replace(array("\n", "\r"), '', $url);
 
   // Before the redirect, allow modules to react to the end of the page request.
   module_invoke_all('exit', $url);
 
+  // Even though session_write_close() is registered as a shutdown function, we
+  // need all session data written to the database before redirecting.
+  session_write_close();
+
   header('Location: '. $url, TRUE, $http_response_code);
 
   // The "Location" header sends a REDIRECT status code to the http
@@ -349,8 +372,10 @@
     menu_set_active_item('');
   }
 
-  if (empty($return)) {
+  if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
     drupal_set_title(t('Page not found'));
+    menu_set_active_item('');
+    $return = '';
   }
   // To conserve CPU and bandwidth, omit the blocks
   print theme('page', $return, FALSE);
@@ -363,7 +388,7 @@
   drupal_set_header('HTTP/1.1 403 Forbidden');
   watchdog('access denied', check_plain($_GET['q']), WATCHDOG_WARNING);
 
-// Keep old path for reference
+  // Keep old path for reference
   if (!isset($_REQUEST['destination'])) {
     $_REQUEST['destination'] = $_GET['q'];
   }
@@ -378,8 +403,9 @@
     menu_set_active_item('');
   }
 
-  if (empty($return)) {
+  if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
     drupal_set_title(t('Access denied'));
+    menu_set_active_item('');
     $return = t('You are not authorized to access this page.');
   }
   print theme('page', $return);
@@ -411,6 +437,19 @@
 
   // Parse the URL, and make sure we can handle the schema.
   $uri = parse_url($url);
+
+  if ($uri == FALSE) {
+    $result->error = 'unable to parse URL';
+    $result->code = -1001;
+    return $result;
+  }
+
+  if (!isset($uri['scheme'])) {
+    $result->error = 'missing schema';
+    $result->code = -1002;
+    return $result;
+  }
+
   switch ($uri['scheme']) {
     case 'http':
       $port = isset($uri['port']) ? $uri['port'] : 80;
@@ -425,12 +464,14 @@
       break;
     default:
       $result->error = 'invalid schema '. $uri['scheme'];
+      $result->code = -1003;
       return $result;
   }
 
   // Make sure the socket opened properly.
   if (!$fp) {
     $result->error = trim($errno .' '. $errstr);
+    $result->code = -$errno;
     return $result;
   }
 
@@ -450,6 +491,11 @@
     'Content-Length' => 'Content-Length: '. strlen($data)
   );
 
+  // If the server url has a user then attempt to use basic authentication
+  if (isset($uri['user'])) {
+    $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
+  }
+
   foreach ($headers as $header => $value) {
     $defaults[$header] = $header .': '. $value;
   }
@@ -544,11 +590,11 @@
   }
 
   if ($errno & (E_ALL ^ E_NOTICE)) {
-    $types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning');
+    $types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning', 4096 => 'recoverable fatal error');
     $entry = $types[$errno] .': '. $message .' in '. $filename .' on line '. $line .'.';
 
     // Force display of error messages in update.php
-    if (variable_get('error_level', 1) == 1 || strstr($_SERVER['PHP_SELF'], 'update.php')) {
+    if (variable_get('error_level', 1) == 1 || strstr($_SERVER['SCRIPT_NAME'], 'update.php')) {
       drupal_set_message($entry, 'error');
     }
 
@@ -629,8 +675,8 @@
 /**
  * Translate strings to the current locale.
  *
- * All human-readable text that will be displayed somewhere within a page should be
- * run through the t() function.
+ * Human-readable text that will be displayed somewhere within a page should
+ * be run through the t() function.
  *
  * Examples:
  * @code
@@ -666,27 +712,27 @@
  *     $message[] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => url("user/$account->uid", NULL, NULL, TRUE)));
  *   @endcode
  *
- * - @variable, which indicates that the text should be run through check_plain,
- *   to strip out HTML characters. Use this for any output that's displayed within
- *   a Drupal page.
+ * - @variable, which indicates that the text should be run through
+ *   check_plain, to escape HTML characters. Use this for any output that's
+ *   displayed within a Drupal page.
  *   @code
  *     drupal_set_title($title = t("@name's blog", array('@name' => $account->name)));
  *   @endcode
  *
- * - %variable, which indicates that the string should be highlighted with
- *   theme_placeholder() which shows up by default as <em>emphasized</em>.
+ * - %variable, which indicates that the string should be HTML escaped and
+ *   highlighted with theme_placeholder() which shows up by default as
+ *   <em>emphasized</em>.
  *   @code
- *     watchdog('mail', t('%name-from sent %name-to an e-mail.', array('%name-from' => $user->name, '%name-to' => $account->name)));
+ *     $message = t('%name-from sent %name-to an e-mail.', array('%name-from' => $user->name, '%name-to' => $account->name));
  *   @endcode
  *
  * When using t(), try to put entire sentences and strings in one t() call.
  * This makes it easier for translators, as it provides context as to what
- * each word refers to. HTML markup within translation strings is allowed,
- * but should be avoided if possible. The exception is embedded links; link
- * titles add additional context for translators so should be kept in the main
- * string.
+ * each word refers to. HTML markup within translation strings is allowed, but
+ * should be avoided if possible. The exception are embedded links; link
+ * titles add a context for translators, so should be kept in the main string.
  *
- * Here is an example of an incorrect use if t():
+ * Here is an example of incorrect usage of t():
  * @code
  *   $output .= t('<p>Go to the @contact-page.</p>', array('@contact-page' => l(t('contact page'), 'contact')));
  * @endcode
@@ -696,7 +742,7 @@
  *   $output .= '<p>'. t('Go to the <a href="@contact-page">contact page</a>.', array('@contact-page' => url('contact'))) .'</p>';
  * @endcode
  *
- * Also avoid escaping quotation marks wherever possible.
+ * Avoid escaping quotation marks wherever possible.
  *
  * Incorrect:
  * @code
@@ -708,6 +754,101 @@
  *   $output .= t("Don't click me.");
  * @endcode
  *
+ * Because t() is designed for handling code-based strings, in almost all
+ * cases, the actual string and not a variable must be passed through t().
+ *
+ * Extraction of translations is done based on the strings contained in t()
+ * calls. If a variable is passed through t(), the content of the variable
+ * cannot be extracted from the file for translation.
+ *
+ * Incorrect:
+ * @code
+ *   $message = 'An error occurred.';
+ *   drupal_set_message(t($message), 'error');
+ *   $output .= t($message);
+ * @endcode
+ *
+ * Correct:
+ * @code
+ *   $message = t('An error occurred.');
+ *   drupal_set_message($message, 'error');
+ *   $output .= $message;
+ * @endcode
+ *
+ * The only case in which variables can be passed safely through t() is when
+ * code-based versions of the same strings will be passed through t() (or
+ * otherwise extracted) elsewhere.
+ *
+ * In some cases, modules may include strings in code that can't use t()
+ * calls. For example, a module may use an external PHP application that
+ * produces strings that are loaded into variables in Drupal for output.
+ * In these cases, module authors may include a dummy file that passes the
+ * relevant strings through t(). This approach will allow the strings to be
+ * extracted.
+ *
+ * Sample external (non-Drupal) code:
+ * @code
+ *   class Time {
+ *     public $yesterday = 'Yesterday';
+ *     public $today = 'Today';
+ *     public $tomorrow = 'Tomorrow';
+ *   }
+ * @endcode
+ *
+ * Sample dummy file.
+ * @code
+ *   // Dummy function included in example.potx.inc.
+ *   function example_potx() {
+ *     $strings = array(
+ *       t('Yesterday'),
+ *       t('Today'),
+ *       t('Tomorrow'),
+ *     );
+ *     // No return value needed, since this is a dummy function.
+ *   }
+ * @endcode
+ *
+ * Having passed strings through t() in a dummy function, it is then
+ * okay to pass variables through t().
+ *
+ * Correct (if a dummy file was used):
+ * @code
+ *   $time = new Time();
+ *   $output .= t($time->today);
+ * @endcode
+ *
+ * However tempting it is, custom data from user input or other non-code
+ * sources should not be passed through t(). Doing so leads to the following
+ * problems and errors:
+ *  - The t() system doesn't support updates to existing strings. When user
+ *    data is updated, the next time it's passed through t() a new record is
+ *    created instead of an update. The database bloats over time and any
+ *    existing translations are orphaned with each update.
+ *  - The t() system assumes any data it receives is in English. User data may
+ *    be in another language, producing translation errors.
+ *  - The "Built-in interface" text group in the locale system is used to
+ *    produce translations for storage in .po files. When non-code strings are
+ *    passed through t(), they are added to this text group, which is rendered
+ *    inaccurate since it is a mix of actual interface strings and various user
+ *    input strings of uncertain origin.
+ *
+ * Incorrect:
+ * @code
+ *   $item = item_load();
+ *   $output .= check_plain(t($item['title']));
+ * @endcode
+ *
+ * Instead, translation of these data can be done through the locale system,
+ * either directly or through helper functions provided by contributed
+ * modules.
+ * @see hook_locale()
+ *
+ * During installation, st() is used in place of t(). Code that may be called
+ * during installation or during normal operation should use the get_t()
+ * helper function.
+ * @see st()
+ * @see get_t()
+ *
  * @param $string
  *   A string containing the English string to translate.
  * @param $args
@@ -780,7 +921,7 @@
  *
  * This function should only be used on actual URLs. It should not be used for
  * Drupal menu paths, which can contain arbitrary characters.
- *
+ * Valid values per RFC 3986.
  * @param $url
  *   The URL to verify.
  * @param $absolute
@@ -789,12 +930,26 @@
  *   TRUE if the URL is in a valid format.
  */
 function valid_url($url, $absolute = FALSE) {
-  $allowed_characters = '[a-z0-9\/:_\-_\.\?\$,;~=#&%\+]';
   if ($absolute) {
-    return preg_match("/^(http|https|ftp):\/\/". $allowed_characters ."+$/i", $url);
+    return (bool)preg_match("
+      /^                                                      # Start at the beginning of the text
+      (?:ftp|https?):\/\/                                     # Look for ftp, http, or https schemes
+      (?:                                                     # Userinfo (optional) which is typically
+        (?:(?:[\w\.\-\+!$&'\(\)*\+,;=]|%[0-9a-f]{2})+:)*      # a username or a username and password
+        (?:[\w\.\-\+%!$&'\(\)*\+,;=]|%[0-9a-f]{2})+@          # combination
+      )?
+      (?:
+        (?:[a-z0-9\-\.]|%[0-9a-f]{2})+                        # A domain name or a IPv4 address
+        |(?:\[(?:[0-9a-f]{0,4}:)*(?:[0-9a-f]{0,4})\])         # or a well formed IPv6 address
+      )
+      (?::[0-9]+)?                                            # Server port number (optional)
+      (?:[\/|\?]
+        (?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})   # The path and query (optional)
+      *)?
+    $/xi", $url);
   }
   else {
-    return preg_match("/^". $allowed_characters ."+$/i", $url);
+    return (bool)preg_match("/^(?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})+$/i", $url);
   }
 }
 
@@ -1164,7 +1319,7 @@
   static $script;
   static $clean_url;
 
-  if (empty($script)) {
+  if (!isset($script)) {
     // On some web servers, such as IIS, we can't omit "index.php". So, we
     // generate "index.php?q=foo" instead of "?q=foo" on anything that is not
     // Apache.
@@ -1262,7 +1417,7 @@
  *   an HTML string containing a link to the given path.
  */
 function l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE) {
-  if ($path == $_GET['q']) {
+  if (($path == $_GET['q']) || ($path == '<front>' && drupal_is_front_page())) {
     if (isset($attributes['class'])) {
       $attributes['class'] .= ' active';
     }
@@ -1511,6 +1666,8 @@
       foreach ($type as $file => $cache) {
         if ($cache) {
           $contents = file_get_contents($file);
+          // Remove multiple charset declarations for standards compliance (and fixing Safari problems)
+          $contents = preg_replace('/^@charset\s+[\'"](\S*)\b[\'"];/i', '', $contents);
           // Return the path to where this CSS file originated from, stripping off the name of the file at the end of the path.
           $path = base_path() . substr($file, 0, strrpos($file, '/')) .'/';
           // Wraps all @import arguments in url().
@@ -1545,6 +1702,8 @@
  */
 function drupal_clear_css_cache() {
   file_scan_directory(file_create_path('css'), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE);
+  // Clear the page cache, so cached pages do not reference nonexistent CSS.
+  cache_clear_all();
 }
 
 /**
@@ -1644,10 +1803,10 @@
  * are added to the page. Then, all settings are output, followed by 'inline'
  * JavaScript code.
  *
- * @parameter $scope
+ * @param $scope
  *   (optional) The scope for which the JavaScript rules should be returned.
  *   Defaults to 'header'.
- * @parameter $javascript
+ * @param $javascript
  *   (optional) An array with all JavaScript code. Defaults to the default
  *   JavaScript array for the given scope.
  * @return
@@ -1699,14 +1858,17 @@
                               array('\r', '\n', '\x3c', '\x3e', '\x26'),
                               addslashes($var)) .'"';
     case 'array':
-      if (array_keys($var) === range(0, sizeof($var) - 1)) {
+      // Arrays in JSON can't be associative. If the array is empty or if it
+      // has sequential whole number keys starting with 0, it's not associative
+      // so we can go ahead and convert it as an array.
+      if (empty ($var) || array_keys($var) === range(0, sizeof($var) - 1)) {
         $output = array();
         foreach ($var as $v) {
           $output[] = drupal_to_js($v);
         }
         return '[ '. implode(', ', $output) .' ]';
       }
-      // Fall through
+      // Otherwise, fall through to convert the array as an object.
     case 'object':
       $output = array();
       foreach ($var as $k => $v) {
@@ -1728,17 +1890,19 @@
  * Notes:
  * - For esthetic reasons, we do not escape slashes. This also avoids a 'feature'
  *   in Apache where it 404s on any path containing '%2F'.
- * - mod_rewrite's unescapes %-encoded ampersands and hashes when clean URLs
- *   are used, which are interpreted as delimiters by PHP. These characters are
- *   double escaped so PHP will still see the encoded version.
+ * - mod_rewrite unescapes %-encoded ampersands, hashes, and slashes when clean
+ *   URLs are used, which are interpreted as delimiters by PHP. These
+ *   characters are double escaped so PHP will still see the encoded version.
+ * - With clean URLs, Apache changes '//' to '/', so every second slash is
+ *   double escaped.
  *
  * @param $text
  *   String to encode
  */
 function drupal_urlencode($text) {
   if (variable_get('clean_url', '0')) {
-    return str_replace(array('%2F', '%26', '%23'),
-                       array('/', '%2526', '%2523'),
+    return str_replace(array('%2F', '%26', '%23', '//'),
+                       array('/', '%2526', '%2523', '/%252F'),
                        urlencode($text));
   }
   else {
@@ -1891,8 +2055,7 @@
 
 /**
  * Send an e-mail message, using Drupal variables and default settings.
- * More information in the <a href="http://php.net/manual/en/function.mail.php">
- * PHP function reference for mail()</a>
+ * More information in the PHP function reference for mail()
  * @param $mailkey
  *   A key to identify the mail sent, for altering.
  * @param $to
@@ -1908,7 +2071,7 @@
  * @param $body
  *   Message to be sent. Drupal will format the correct line endings for you.
  * @param $from
- *   Sets From, Reply-To, Return-Path and Error-To to this value, if given.
+ *   Sets From to this value, if given.
  * @param $headers
  *   Associative array containing the headers to add. This is typically
  *   used to add extra headers (From, Cc, and Bcc).
@@ -1923,8 +2086,15 @@
     'Content-Transfer-Encoding' => '8Bit',
     'X-Mailer' => 'Drupal'
   );
-  if (isset($from)) {
-    $defaults['From'] = $defaults['Reply-To'] = $defaults['Return-Path'] = $defaults['Errors-To'] = $from;
+  // To prevent e-mail from looking like spam, the addresses in the Sender and
+  // Return-Path headers should have a domain authorized to use the originating
+  // SMTP server.  Errors-To is redundant, but shouldn't hurt.
+  $default_from = variable_get('site_mail', ini_get('sendmail_from'));
+  if ($default_from) {
+    $defaults['From'] = $defaults['Sender'] = $defaults['Return-Path'] = $defaults['Errors-To'] = $default_from;
+  }
+  if ($from) {
+    $defaults['From'] = $from;
   }
   $headers = array_merge($defaults, $headers);
   // Custom hook traversal to allow pass by reference
@@ -1938,26 +2108,24 @@
     return drupal_mail_wrapper($mailkey, $to, $subject, $body, $from, $headers);
   }
   else {
-    /*
-    ** Note: if you are having problems with sending mail, or mails look wrong
-    ** when they are received you may have to modify the str_replace to suit
-    ** your systems.
-    **  - \r\n will work under dos and windows.
-    **  - \n will work for linux, unix and BSDs.
-    **  - \r will work for macs.
-    **
-    ** According to RFC 2646, it's quite rude to not wrap your e-mails:
-    **
-    ** "The Text/Plain media type is the lowest common denominator of
-    ** Internet e-mail, with lines of no more than 997 characters (by
-    ** convention usually no more than 80), and where the CRLF sequence
-    ** represents a line break [MIME-IMT]."
-    **
-    ** CRLF === \r\n
-    **
-    ** http://www.rfc-editor.org/rfc/rfc2646.txt
-    **
-    */
+    // Note: if you are having problems with sending mail, or mails look wrong
+    // when they are received you may have to modify the str_replace to suit
+    // your systems.
+    //  - \r\n will work under dos and windows.
+    //  - \n will work for linux, unix and BSDs.
+    //  - \r will work for macs.
+    //
+    // According to RFC 2646, it's quite rude to not wrap your e-mails:
+    //
+    // "The Text/Plain media type is the lowest common denominator of
+    // Internet e-mail, with lines of no more than 997 characters (by
+    // convention usually no more than 80), and where the CRLF sequence
+    // represents a line break [MIME-IMT]."
+    //
+    // CRLF === \r\n
+    //
+    // http://www.rfc-editor.org/rfc/rfc2646.txt
+
     $mimeheaders = array();
     foreach ($headers as $name => $value) {
       $mimeheaders[] = $name .': '. mime_header_encode($value);
diff -Naur drupal-5.0/includes/database.inc drupal-5.23/includes/database.inc
--- drupal-5.0/includes/database.inc	2007-01-03 11:59:02.000000000 +0100
+++ drupal-5.23/includes/database.inc	2008-01-07 01:55:44.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: database.inc,v 1.62 2007/01/03 10:59:02 dries Exp $
+// $Id: database.inc,v 1.62.2.6 2008/01/07 00:55:44 drumm Exp $
 
 /**
  * @file
@@ -100,7 +100,7 @@
  */
 function db_set_active($name = 'default') {
   global $db_url, $db_type, $active_db;
-  static $db_conns;
+  static $db_conns, $active_name = FALSE;
 
   if (!isset($db_conns[$name])) {
     // Initiate a new connection, using the named DB URL specified.
@@ -128,11 +128,12 @@
     $db_conns[$name] = db_connect($connect_url);
   }
 
-  $previous_db = $active_db;
+  $previous_name = $active_name;
   // Set the active connection.
+  $active_name = $name;
   $active_db = $db_conns[$name];
 
-  return array_search($previous_db, $db_conns);
+  return $previous_name;
 }
 
 /**
@@ -177,7 +178,7 @@
  *   A variable number of arguments which are substituted into the query
  *   using printf() syntax. Instead of a variable number of query arguments,
  *   you may also pass a single array containing the query arguments.
-
+ *
  *   Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
  *   in '') and %%.
  *
@@ -203,7 +204,7 @@
 /**
  * Helper function for db_rewrite_sql.
  *
- * Collects JOIN and WHERE statements via hook_sql.
+ * Collects JOIN and WHERE statements via hook_db_rewrite_sql().
  * Decides whether to select primary_key or DISTINCT(primary_key)
  *
  * @param $query
@@ -252,7 +253,7 @@
  * @param $query
  *   Query to be rewritten.
  * @param $primary_table
- *   Name or alias of the table which has the primary key field for this query. Possible values are: comments, forum, node, menu, term_data, vocabulary.
+ *   Name or alias of the table which has the primary key field for this query. Possible values are: {comments}, {forum}, {node}, {menu}, {term_data}, {vocabulary}.
  * @param $primary_field
  *   Name of the primary field.
  * @param $args
@@ -282,6 +283,9 @@
     if (strpos($query, 'GROUP')) {
       $replace = 'GROUP';
     }
+    elseif (strpos($query, 'HAVING')) {
+      $replace = 'HAVING';
+    }
     elseif (strpos($query, 'ORDER')) {
       $replace = 'ORDER';
     }
diff -Naur drupal-5.0/includes/database.mysql.inc drupal-5.23/includes/database.mysql.inc
--- drupal-5.0/includes/database.mysql.inc	2006-12-27 23:50:09.000000000 +0100
+++ drupal-5.23/includes/database.mysql.inc	2009-07-10 08:09:38.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: database.mysql.inc,v 1.66 2006/12/27 22:50:09 dries Exp $
+// $Id: database.mysql.inc,v 1.66.2.4 2009/07/10 06:09:38 drumm Exp $
 
 /**
  * @file
@@ -53,17 +53,23 @@
  * (e.g. your database and web server live on different machines).
  */
 function db_connect($url) {
+  $url = parse_url($url);
+
   // Check if MySQL support is present in PHP
   if (!function_exists('mysql_connect')) {
+    // Redirect to installer if using default DB credentials
+    if ($url['user'] == 'username' && $url['pass'] == 'password') {
+      include_once 'includes/install.inc';
+      install_goto('install.php');
+    }
     drupal_maintenance_theme();
+    drupal_set_header('HTTP/1.1 503 Service Unavailable');
     drupal_set_title('PHP MySQL support not enabled');
     print theme('maintenance_page', '<p>We were unable to use the MySQL database because the MySQL extension for PHP is not installed. Check your <code>PHP.ini</code> to see how you can enable it.</p>
 <p>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>');
     exit;
   }
 
-  $url = parse_url($url);
-
   // Decode url-encoded information in the db connection string
   $url['user'] = urldecode($url['user']);
   // Test if database url has a password.
@@ -100,7 +106,7 @@
     drupal_set_header('HTTP/1.1 503 Service Unavailable');
     drupal_set_title('Unable to connect to database server');
     print theme('maintenance_page', '<p>If you still have to install Drupal, proceed to the <a href="'. base_path() .'install.php">installation page</a>.</p>
-<p>If you have already finished installed Drupal, this either means that the username and password information in your <code>settings.php</code> file is incorrect or that we can\'t connect to the MySQL database server. This could mean your hosting provider\'s database server is down.</p>
+<p>If you have already finished installing Drupal, this either means that the username and password information in your <code>settings.php</code> file is incorrect or that we can\'t connect to the MySQL database server. This could mean your hosting provider\'s database server is down.</p>
 <p>The MySQL error was: '. theme('placeholder', mysql_error()) .'.</p>
 <p>Currently, the username is '. theme('placeholder', $url['user']) .' and the database server is '. theme('placeholder', $url['host']) .'.</p>
 <ul>
@@ -114,6 +120,7 @@
 
   if (!mysql_select_db(substr($url['path'], 1))) {
     drupal_maintenance_theme();
+    drupal_set_header('HTTP/1.1 503 Service Unavailable');
     drupal_set_title('Unable to select database');
     print theme('maintenance_page', '<p>We were able to connect to the MySQL database server (which means your username and password are okay) but not able to select the database.</p>
 <p>The MySQL error was: '. theme('placeholder', mysql_error($connection)) .'.</p>
@@ -353,7 +360,7 @@
   $tablename = array_pop($args);
   array_shift($args);
 
-  $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE '. $tablename .' SELECT', db_prefix_tables($query));
+  $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE '. $tablename .' Engine=HEAP SELECT', db_prefix_tables($query));
   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
     $args = $args[0];
   }
diff -Naur drupal-5.0/includes/database.mysqli.inc drupal-5.23/includes/database.mysqli.inc
--- drupal-5.0/includes/database.mysqli.inc	2006-12-27 23:50:09.000000000 +0100
+++ drupal-5.23/includes/database.mysqli.inc	2009-07-10 08:09:38.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: database.mysqli.inc,v 1.32 2006/12/27 22:50:09 dries Exp $
+// $Id: database.mysqli.inc,v 1.32.2.6 2009/07/10 06:09:38 drumm Exp $
 
 /**
  * @file
@@ -56,6 +56,7 @@
   // Check if MySQLi support is present in PHP
   if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
     drupal_maintenance_theme();
+    drupal_set_header('HTTP/1.1 503 Service Unavailable');
     drupal_set_title('PHP MySQLi support not enabled');
     print theme('maintenance_page', '<p>We were unable to use the MySQLi database because the MySQLi extension for PHP is not installed. Check your <code>PHP.ini</code> to see how you can enable it.</p>
 <p>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>');
@@ -75,6 +76,9 @@
   }
   $url['host'] = urldecode($url['host']);
   $url['path'] = urldecode($url['path']);
+  if (!isset($url['port'])) {
+    $url['port'] = NULL;
+  }
 
   $connection = mysqli_init();
   @mysqli_real_connect($connection, $url['host'], $url['user'], $url['pass'], substr($url['path'], 1), $url['port'], NULL, MYSQLI_CLIENT_FOUND_ROWS);
@@ -85,8 +89,8 @@
     drupal_set_header('HTTP/1.1 503 Service Unavailable');
     drupal_set_title('Unable to connect to database server');
     print theme('maintenance_page', '<p>If you still have to install Drupal, proceed to the <a href="'. base_path() .'install.php">installation page</a>.</p>
-<p>If you have already finished installed Drupal, this either means that the username and password information in your <code>settings.php</code> file is incorrect or that we can\'t connect to the MySQL database server. This could mean your hosting provider\'s database server is down.</p>
-<p>The MySQL error was: '. theme('placeholder', mysqli_error($connection)) .'.</p>
+<p>If you have already finished installing Drupal, this either means that the username and password information in your <code>settings.php</code> file is incorrect or that we can\'t connect to the MySQL database server. This could mean your hosting provider\'s database server is down.</p>
+<p>The MySQL error was: '. theme('placeholder', mysqli_connect_error($connection)) .'.</p>
 <p>Currently, the username is '. theme('placeholder', $url['user']) .' and the database server is '. theme('placeholder', $url['host']) .'.</p>
 <ul>
   <li>Are you sure you have the correct username and password?</li>
@@ -99,9 +103,10 @@
   }
   else if (mysqli_connect_errno() > 0) {
     drupal_maintenance_theme();
+    drupal_set_header('HTTP/1.1 503 Service Unavailable');
     drupal_set_title('Unable to select database');
     print theme('maintenance_page', '<p>We were able to connect to the MySQL database server (which means your username and password are okay) but not able to select the database.</p>
-<p>The MySQL error was: '. theme('placeholder', mysqli_error($connection)) .'.</p>
+<p>The MySQL error was: '. theme('placeholder', mysqli_connect_error($connection)) .'.</p>
 <p>Currently, the database is '. theme('placeholder', substr($url['path'], 1)) .'. The username is '. theme('placeholder', $url['user']) .' and the database server is '. theme('placeholder', $url['host']) .'.</p>
 <ul>
   <li>Are you sure you have the correct database name?</li>
@@ -199,18 +204,18 @@
 }
 
 /**
-* Return an individual result field from the previous query.
-*
-* Only use this function if exactly one field is being selected; otherwise,
-* use db_fetch_object() or db_fetch_array().
-*
-* @param $result
-*   A database query result resource, as returned from db_query().
-* @param $row
-*   The index of the row whose result is needed.
-* @return
-*   The resulting field or FALSE.
-*/
+ * Return an individual result field from the previous query.
+ *
+ * Only use this function if exactly one field is being selected; otherwise,
+ * use db_fetch_object() or db_fetch_array().
+ *
+ * @param $result
+ *   A database query result resource, as returned from db_query().
+ * @param $row
+ *   The index of the row whose result is needed.
+ * @return
+ *   The resulting field or FALSE.
+ */
 function db_result($result, $row = 0) {
   if ($result && mysqli_num_rows($result) > $row) {
     $array = mysqli_fetch_array($result, MYSQLI_NUM);
@@ -338,7 +343,7 @@
   $tablename = array_pop($args);
   array_shift($args);
 
-  $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE '. $tablename .' SELECT', db_prefix_tables($query));
+  $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE '. $tablename .' Engine=HEAP SELECT', db_prefix_tables($query));
   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
     $args = $args[0];
   }
diff -Naur drupal-5.0/includes/database.pgsql.inc drupal-5.23/includes/database.pgsql.inc
--- drupal-5.0/includes/database.pgsql.inc	2006-12-27 23:13:56.000000000 +0100
+++ drupal-5.23/includes/database.pgsql.inc	2008-09-15 08:14:52.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: database.pgsql.inc,v 1.43 2006/12/27 22:13:56 dries Exp $
+// $Id: database.pgsql.inc,v 1.43.2.3 2008/09/15 06:14:52 drumm Exp $
 
 /**
  * @file
@@ -54,6 +54,7 @@
    // Check if MySQL support is present in PHP
   if (!function_exists('pg_connect')) {
     drupal_maintenance_theme();
+    drupal_set_header('HTTP/1.1 503 Service Unavailable');
     drupal_set_title('PHP PostgreSQL support not enabled');
     print theme('maintenance_page', '<p>We were unable to use the PostgreSQL database because the PostgreSQL extension for PHP is not installed. Check your <code>PHP.ini</code> to see how you can enable it.</p>
 <p>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>');
@@ -92,7 +93,7 @@
     drupal_set_header('HTTP/1.1 503 Service Unavailable');
     drupal_set_title('Unable to connect to database');
     print theme('maintenance_page', '<p>If you still have to install Drupal, proceed to the <a href="'. base_path() .'install.php">installation page</a>.</p>
-<p>If you have already finished installed Drupal, this either means that the username and password information in your <code>settings.php</code> file is incorrect or that we can\'t connect to the PostgreSQL database server. This could mean your hosting provider\'s database server is down.</p>
+<p>If you have already finished installing Drupal, this either means that the username and password information in your <code>settings.php</code> file is incorrect or that we can\'t connect to the PostgreSQL database server. This could mean your hosting provider\'s database server is down.</p>
 <p>The PostgreSQL error was: '. theme('placeholder', decode_entities($php_errormsg)) .'</p>
 <p>Currently, the database is '. theme('placeholder', substr($url['path'], 1)) .', the username is '. theme('placeholder', $url['user']) .', and the database server is '. theme('placeholder', $url['host']) .'.</p>
 <ul>
@@ -418,10 +419,14 @@
  * @return SQL query with the DISTINCT wrapper surrounding the given table.field.
  */
 function db_distinct_field($table, $field, $query) {
-  $field_to_select = 'DISTINCT ON ('. $table .'.'. $field .") $table.$field";
-  // (?<!text) is a negative look-behind (no need to rewrite queries that already use DISTINCT).
-  $query = preg_replace('/(SELECT.*)(?:'. $table .'\.|\s)(?<!DISTINCT\()(?<!DISTINCT\('. $table .'\.)'. $field .'(.*FROM )/AUsi', '\1 '. $field_to_select .'\2', $query);
-  $query = preg_replace('/(ORDER BY )(?!'.$table.'\.'.$field.')/', '\1'."$table.$field, ", $query);
+  if (!preg_match('/FROM\s+\S+\s+AS/si', $query)
+    && !preg_match('/DISTINCT\s+ON\s*\(\s*(' . $table . '\s*\.\s*)?' . $field . '\s*\)/si', $query)
+    && !preg_match('/DISTINCT[ (]' . $field . '/si', $query)
+    && preg_match('/(.*FROM\s+)(.*?\s)(\s*(WHERE|GROUP|HAVING|ORDER|LIMIT|FOR).*)/Asi', $query, $m)) {
+      $query = $m[1];
+      $query .= preg_replace('/([\{\w+\}]+)\s+(' . $table . ')\s/Usi', '(SELECT DISTINCT ON (' . $field . ') * FROM \1) \2 ', $m[2]);
+      $query .= $m[3];
+  }
   return $query;
 }
 
diff -Naur drupal-5.0/includes/file.inc drupal-5.23/includes/file.inc
--- drupal-5.0/includes/file.inc	2007-01-05 06:32:22.000000000 +0100
+++ drupal-5.23/includes/file.inc	2009-01-26 15:22:45.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: file.inc,v 1.90 2007/01/05 05:32:22 unconed Exp $
+// $Id: file.inc,v 1.90.2.7 2009/01/26 14:22:45 drumm Exp $
 
 /**
  * @file
@@ -154,20 +154,17 @@
 
 
 /**
- * Check if $source is a valid file upload. If so, move the file to Drupal's tmp dir
- * and return it as an object.
+ * Verify an uploaded file.
  *
- * The use of SESSION['file_uploads'] should probably be externalized to upload.module
- *
- * @todo Rename file_check_upload to file_prepare upload.
- * @todo Refactor or merge file_save_upload.
- * @todo Extenalize SESSION['file_uploads'] to modules.
- *
- * @param $source An upload source (the name of the upload form item), or a file
- * @return FALSE for an invalid file or upload. A file object for valid uploads/files.
+ * Check if $source is a valid file upload. If so, move the file to the
+ * temporary directory and return it as an object.
  *
+ * @param $source
+ *   An upload source (the name of the upload form item), or a file.
+ * @return
+ *   FALSE for an invalid file or upload. A file object for valid
+ *   uploads/files.
  */
-
 function file_check_upload($source = 'upload') {
   // Cache for uploaded files. Since the data in _FILES is modified
   // by this function, we cache the result.
@@ -223,10 +220,11 @@
     $file = new stdClass();
     $file->filename = trim(basename($_FILES["files"]["name"][$source]), '.');
 
-    // Create temporary name/path for newly uploaded files.
-    $file->filepath = tempnam(file_directory_temp(), 'tmp_');
+    // Create temporary name/path for newly uploaded files. On Windows, tempnam()
+    // requires an absolute path, so we use realpath().
+    $file->filepath = tempnam(realpath(file_directory_temp()), 'tmp_');
 
-    $file->filemime = $_FILES["files"]["type"][$source];
+    $file->filemime = file_get_mimetype($file->filename);
 
     // Rename potentially executable files, to help prevent exploits.
     if (preg_match('/\.(php|pl|py|cgi|asp|js)$/i', $file->filename) && (substr($file->filename, -4) != '.txt')) {
@@ -523,7 +521,8 @@
  */
 function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) {
   $temp = file_directory_temp();
-  $file = tempnam($temp, 'file');
+  // On Windows, tempnam() requires an absolute path, so we use realpath().
+  $file = tempnam(realpath($temp), 'file');
   if (!$fp = fopen($file, 'wb')) {
     drupal_set_message(t('The file could not be created.'), 'error');
     return 0;
@@ -553,7 +552,7 @@
     // not followed by a space or a tab.
     // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
     $header = preg_replace('/\r?\n(?!\t| )/', '', $header);
-    header($header);
+    drupal_set_header($header);
   }
 
   $source = file_create_path($source);
@@ -639,7 +638,7 @@
   $files = array();
 
   if (is_dir($dir) && $handle = opendir($dir)) {
-    while ($file = readdir($handle)) {
+    while (FALSE !== ($file = readdir($handle))) {
       if (!in_array($file, $nomask) && $file[0] != '.') {
         if (is_dir("$dir/$file") && $recurse) {
           $files = array_merge($files, file_scan_directory("$dir/$file", $mask, $nomask, $callback, $recurse, $key, $min_depth, $depth + 1));
@@ -719,16 +718,387 @@
  * Determine the maximum file upload size by querying the PHP settings.
  *
  * @return
- *   A file size limit in MB based on the PHP upload_max_filesize and post_max_size
+ *   A file size limit in bytes based on the PHP upload_max_filesize and post_max_size
  */
 function file_upload_max_size() {
   static $max_size = -1;
 
   if ($max_size < 0) {
     $upload_max = parse_size(ini_get('upload_max_filesize'));
-    // sanity check- a single upload should not be more than 50% the size limit of the total post
-    $post_max = parse_size(ini_get('post_max_size')) / 2;
+    $post_max = parse_size(ini_get('post_max_size'));
     $max_size = ($upload_max < $post_max) ? $upload_max : $post_max;
   }
   return $max_size;
 }
+
+/**
+ * Determine an Internet Media Type, or MIME type from a filename.
+ *
+ * @param $filename
+ *   Name of the file, including extension.
+ * @param $mapping
+ *   An optional array of extension to media type mappings in the form
+ *   'extension1|extension2|...' => 'type'.
+ *
+ * @return
+ *   The internet media type registered for the extension or application/octet-stream for unknown extensions.
+ */
+function file_get_mimetype($filename, $mapping = NULL) {
+  if (!is_array($mapping)) {
+    $mapping = variable_get('mime_extension_mapping', array(
+      'ez' => 'application/andrew-inset',
+      'atom' => 'application/atom',
+      'atomcat' => 'application/atomcat+xml',
+      'atomsrv' => 'application/atomserv+xml',
+      'cap|pcap' => 'application/cap',
+      'cu' => 'application/cu-seeme',
+      'tsp' => 'application/dsptype',
+      'spl' => 'application/x-futuresplash',
+      'hta' => 'application/hta',
+      'jar' => 'application/java-archive',
+      'ser' => 'application/java-serialized-object',
+      'class' => 'application/java-vm',
+      'hqx' => 'application/mac-binhex40',
+      'cpt' => 'image/x-corelphotopaint',
+      'nb' => 'application/mathematica',
+      'mdb' => 'application/msaccess',
+      'doc|dot' => 'application/msword',
+      'bin' => 'application/octet-stream',
+      'oda' => 'application/oda',
+      'ogg|ogx' => 'application/ogg',
+      'pdf' => 'application/pdf',
+      'key' => 'application/pgp-keys',
+      'pgp' => 'application/pgp-signature',
+      'prf' => 'application/pics-rules',
+      'ps|ai|eps' => 'application/postscript',
+      'rar' => 'application/rar',
+      'rdf' => 'application/rdf+xml',
+      'rss' => 'application/rss+xml',
+      'rtf' => 'application/rtf',
+      'smi|smil' => 'application/smil',
+      'wpd' => 'application/wordperfect',
+      'wp5' => 'application/wordperfect5.1',
+      'xhtml|xht' => 'application/xhtml+xml',
+      'xml|xsl' => 'application/xml',
+      'zip' => 'application/zip',
+      'cdy' => 'application/vnd.cinderella',
+      'kml' => 'application/vnd.google-earth.kml+xml',
+      'kmz' => 'application/vnd.google-earth.kmz',
+      'xul' => 'application/vnd.mozilla.xul+xml',
+      'xls|xlb|xlt' => 'application/vnd.ms-excel',
+      'cat' => 'application/vnd.ms-pki.seccat',
+      'stl' => 'application/vnd.ms-pki.stl',
+      'ppt|pps' => 'application/vnd.ms-powerpoint',
+      'odc' => 'application/vnd.oasis.opendocument.chart',
+      'odb' => 'application/vnd.oasis.opendocument.database',
+      'odf' => 'application/vnd.oasis.opendocument.formula',
+      'odg' => 'application/vnd.oasis.opendocument.graphics',
+      'otg' => 'application/vnd.oasis.opendocument.graphics-template',
+      'odi' => 'application/vnd.oasis.opendocument.image',
+      'odp' => 'application/vnd.oasis.opendocument.presentation',
+      'otp' => 'application/vnd.oasis.opendocument.presentation-template',
+      'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
+      'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
+      'odt' => 'application/vnd.oasis.opendocument.text',
+      'odm' => 'application/vnd.oasis.opendocument.text-master',
+      'ott' => 'application/vnd.oasis.opendocument.text-template',
+      'oth' => 'application/vnd.oasis.opendocument.text-web',
+      'docm' => 'application/vnd.ms-word.document.macroEnabled.12',
+      'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+      'dotm' => 'application/vnd.ms-word.template.macroEnabled.12',
+      'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
+      'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
+      'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
+      'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
+      'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
+      'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
+      'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
+      'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+      'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
+      'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
+      'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
+      'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+      'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
+      'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
+      'cod' => 'application/vnd.rim.cod',
+      'mmf' => 'application/vnd.smaf',
+      'sdc' => 'application/vnd.stardivision.calc',
+      'sds' => 'application/vnd.stardivision.chart',
+      'sda' => 'application/vnd.stardivision.draw',
+      'sdd' => 'application/vnd.stardivision.impress',
+      'sdf' => 'application/vnd.stardivision.math',
+      'sdw' => 'application/vnd.stardivision.writer',
+      'sgl' => 'application/vnd.stardivision.writer-global',
+      'sxc' => 'application/vnd.sun.xml.calc',
+      'stc' => 'application/vnd.sun.xml.calc.template',
+      'sxd' => 'application/vnd.sun.xml.draw',
+      'std' => 'application/vnd.sun.xml.draw.template',
+      'sxi' => 'application/vnd.sun.xml.impress',
+      'sti' => 'application/vnd.sun.xml.impress.template',
+      'sxm' => 'application/vnd.sun.xml.math',
+      'sxw' => 'application/vnd.sun.xml.writer',
+      'sxg' => 'application/vnd.sun.xml.writer.global',
+      'stw' => 'application/vnd.sun.xml.writer.template',
+      'sis' => 'application/vnd.symbian.install',
+      'vsd' => 'application/vnd.visio',
+      'wbxml' => 'application/vnd.wap.wbxml',
+      'wmlc' => 'application/vnd.wap.wmlc',
+      'wmlsc' => 'application/vnd.wap.wmlscriptc',
+      'wk' => 'application/x-123',
+      '7z' => 'application/x-7z-compressed',
+      'abw' => 'application/x-abiword',
+      'dmg' => 'application/x-apple-diskimage',
+      'bcpio' => 'application/x-bcpio',
+      'torrent' => 'application/x-bittorrent',
+      'cab' => 'application/x-cab',
+      'cbr' => 'application/x-cbr',
+      'cbz' => 'application/x-cbz',
+      'cdf' => 'application/x-cdf',
+      'vcd' => 'application/x-cdlink',
+      'pgn' => 'application/x-chess-pgn',
+      'cpio' => 'application/x-cpio',
+      'csh' => 'text/x-csh',
+      'deb|udeb' => 'application/x-debian-package',
+      'dcr|dir|dxr' => 'application/x-director',
+      'dms' => 'application/x-dms',
+      'wad' => 'application/x-doom',
+      'dvi' => 'application/x-dvi',
+      'rhtml' => 'application/x-httpd-eruby',
+      'flac' => 'application/x-flac',
+      'pfa|pfb|gsf|pcf|pcf.Z' => 'application/x-font',
+      'mm' => 'application/x-freemind',
+      'gnumeric' => 'application/x-gnumeric',
+      'sgf' => 'application/x-go-sgf',
+      'gcf' => 'application/x-graphing-calculator',
+      'gtar|tgz|taz' => 'application/x-gtar',
+      'hdf' => 'application/x-hdf',
+      'phtml|pht|php' => 'application/x-httpd-php',
+      'phps' => 'application/x-httpd-php-source',
+      'php3' => 'application/x-httpd-php3',
+      'php3p' => 'application/x-httpd-php3-preprocessed',
+      'php4' => 'application/x-httpd-php4',
+      'ica' => 'application/x-ica',
+      'ins|isp' => 'application/x-internet-signup',
+      'iii' => 'application/x-iphone',
+      'iso' => 'application/x-iso9660-image',
+      'jnlp' => 'application/x-java-jnlp-file',
+      'js' => 'application/x-javascript',
+      'jmz' => 'application/x-jmol',
+      'chrt' => 'application/x-kchart',
+      'kil' => 'application/x-killustrator',
+      'skp|skd|skt|skm' => 'application/x-koan',
+      'kpr|kpt' => 'application/x-kpresenter',
+      'ksp' => 'application/x-kspread',
+      'kwd|kwt' => 'application/x-kword',
+      'latex' => 'application/x-latex',
+      'lha' => 'application/x-lha',
+      'lyx' => 'application/x-lyx',
+      'lzh' => 'application/x-lzh',
+      'lzx' => 'application/x-lzx',
+      'frm|maker|frame|fm|fb|book|fbdoc' => 'application/x-maker',
+      'mif' => 'application/x-mif',
+      'wmd' => 'application/x-ms-wmd',
+      'wmz' => 'application/x-ms-wmz',
+      'com|exe|bat|dll' => 'application/x-msdos-program',
+      'msi' => 'application/x-msi',
+      'nc' => 'application/x-netcdf',
+      'pac' => 'application/x-ns-proxy-autoconfig',
+      'nwc' => 'application/x-nwc',
+      'o' => 'application/x-object',
+      'oza' => 'application/x-oz-application',
+      'p7r' => 'application/x-pkcs7-certreqresp',
+      'crl' => 'application/x-pkcs7-crl',
+      'pyc|pyo' => 'application/x-python-code',
+      'qtl' => 'application/x-quicktimeplayer',
+      'rpm' => 'application/x-redhat-package-manager',
+      'sh' => 'text/x-sh',
+      'shar' => 'application/x-shar',
+      'swf|swfl' => 'application/x-shockwave-flash',
+      'sit|sitx' => 'application/x-stuffit',
+      'sv4cpio' => 'application/x-sv4cpio',
+      'sv4crc' => 'application/x-sv4crc',
+      'tar' => 'application/x-tar',
+      'tcl' => 'application/x-tcl',
+      'gf' => 'application/x-tex-gf',
+      'pk' => 'application/x-tex-pk',
+      'texinfo|texi' => 'application/x-texinfo',
+      '~|%|bak|old|sik' => 'application/x-trash',
+      't|tr|roff' => 'application/x-troff',
+      'man' => 'application/x-troff-man',
+      'me' => 'application/x-troff-me',
+      'ms' => 'application/x-troff-ms',
+      'ustar' => 'application/x-ustar',
+      'src' => 'application/x-wais-source',
+      'wz' => 'application/x-wingz',
+      'crt' => 'application/x-x509-ca-cert',
+      'xcf' => 'application/x-xcf',
+      'fig' => 'application/x-xfig',
+      'xpi' => 'application/x-xpinstall',
+      'au|snd' => 'audio/basic',
+      'mid|midi|kar' => 'audio/midi',
+      'mpga|mpega|mp2|mp3|m4a' => 'audio/mpeg',
+      'm3u' => 'audio/x-mpegurl',
+      'oga|spx' => 'audio/ogg',
+      'sid' => 'audio/prs.sid',
+      'aif|aiff|aifc' => 'audio/x-aiff',
+      'gsm' => 'audio/x-gsm',
+      'wma' => 'audio/x-ms-wma',
+      'wax' => 'audio/x-ms-wax',
+      'ra|rm|ram' => 'audio/x-pn-realaudio',
+      'ra' => 'audio/x-realaudio',
+      'pls' => 'audio/x-scpls',
+      'sd2' => 'audio/x-sd2',
+      'wav' => 'audio/x-wav',
+      'alc' => 'chemical/x-alchemy',
+      'cac|cache' => 'chemical/x-cache',
+      'csf' => 'chemical/x-cache-csf',
+      'cbin|cascii|ctab' => 'chemical/x-cactvs-binary',
+      'cdx' => 'chemical/x-cdx',
+      'cer' => 'chemical/x-cerius',
+      'c3d' => 'chemical/x-chem3d',
+      'chm' => 'chemical/x-chemdraw',
+      'cif' => 'chemical/x-cif',
+      'cmdf' => 'chemical/x-cmdf',
+      'cml' => 'chemical/x-cml',
+      'cpa' => 'chemical/x-compass',
+      'bsd' => 'chemical/x-crossfire',
+      'csml|csm' => 'chemical/x-csml',
+      'ctx' => 'chemical/x-ctx',
+      'cxf|cef' => 'chemical/x-cxf',
+      'emb|embl' => 'chemical/x-embl-dl-nucleotide',
+      'spc' => 'chemical/x-galactic-spc',
+      'inp|gam|gamin' => 'chemical/x-gamess-input',
+      'fch|fchk' => 'chemical/x-gaussian-checkpoint',
+      'cub' => 'chemical/x-gaussian-cube',
+      'gau|gjc|gjf' => 'chemical/x-gaussian-input',
+      'gal' => 'chemical/x-gaussian-log',
+      'gcg' => 'chemical/x-gcg8-sequence',
+      'gen' => 'chemical/x-genbank',
+      'hin' => 'chemical/x-hin',
+      'istr|ist' => 'chemical/x-isostar',
+      'jdx|dx' => 'chemical/x-jcamp-dx',
+      'kin' => 'chemical/x-kinemage',
+      'mcm' => 'chemical/x-macmolecule',
+      'mmd|mmod' => 'chemical/x-macromodel-input',
+      'mol' => 'chemical/x-mdl-molfile',
+      'rd' => 'chemical/x-mdl-rdfile',
+      'rxn' => 'chemical/x-mdl-rxnfile',
+      'sd|sdf' => 'chemical/x-mdl-sdfile',
+      'tgf' => 'chemical/x-mdl-tgf',
+      'mcif' => 'chemical/x-mmcif',
+      'mol2' => 'chemical/x-mol2',
+      'b' => 'chemical/x-molconn-Z',
+      'gpt' => 'chemical/x-mopac-graph',
+      'mop|mopcrt|mpc|dat|zmt' => 'chemical/x-mopac-input',
+      'moo' => 'chemical/x-mopac-out',
+      'mvb' => 'chemical/x-mopac-vib',
+      'asn' => 'chemical/x-ncbi-asn1-spec',
+      'prt|ent' => 'chemical/x-ncbi-asn1-ascii',
+      'val|aso' => 'chemical/x-ncbi-asn1-binary',
+      'pdb|ent' => 'chemical/x-pdb',
+      'ros' => 'chemical/x-rosdal',
+      'sw' => 'chemical/x-swissprot',
+      'vms' => 'chemical/x-vamas-iso14976',
+      'vmd' => 'chemical/x-vmd',
+      'xtel' => 'chemical/x-xtel',
+      'xyz' => 'chemical/x-xyz',
+      'gif' => 'image/gif',
+      'ief' => 'image/ief',
+      'jpeg|jpg|jpe' => 'image/jpeg',
+      'pcx' => 'image/pcx',
+      'png' => 'image/png',
+      'svg|svgz' => 'image/svg+xml',
+      'tiff|tif' => 'image/tiff',
+      'djvu|djv' => 'image/vnd.djvu',
+      'wbmp' => 'image/vnd.wap.wbmp',
+      'ras' => 'image/x-cmu-raster',
+      'cdr' => 'image/x-coreldraw',
+      'pat' => 'image/x-coreldrawpattern',
+      'cdt' => 'image/x-coreldrawtemplate',
+      'ico' => 'image/x-icon',
+      'art' => 'image/x-jg',
+      'jng' => 'image/x-jng',
+      'bmp' => 'image/x-ms-bmp',
+      'psd' => 'image/x-photoshop',
+      'pnm' => 'image/x-portable-anymap',
+      'pbm' => 'image/x-portable-bitmap',
+      'pgm' => 'image/x-portable-graymap',
+      'ppm' => 'image/x-portable-pixmap',
+      'rgb' => 'image/x-rgb',
+      'xbm' => 'image/x-xbitmap',
+      'xpm' => 'image/x-xpixmap',
+      'xwd' => 'image/x-xwindowdump',
+      'eml' => 'message/rfc822',
+      'igs|iges' => 'model/iges',
+      'msh|mesh|silo' => 'model/mesh',
+      'wrl|vrml' => 'model/vrml',
+      'ics|icz' => 'text/calendar',
+      'css' => 'text/css',
+      'csv' => 'text/csv',
+      '323' => 'text/h323',
+      'html|htm|shtml' => 'text/html',
+      'uls' => 'text/iuls',
+      'mml' => 'text/mathml',
+      'asc|txt|text|pot' => 'text/plain',
+      'rtx' => 'text/richtext',
+      'sct|wsc' => 'text/scriptlet',
+      'tm|ts' => 'text/texmacs',
+      'tsv' => 'text/tab-separated-values',
+      'jad' => 'text/vnd.sun.j2me.app-descriptor',
+      'wml' => 'text/vnd.wap.wml',
+      'wmls' => 'text/vnd.wap.wmlscript',
+      'bib' => 'text/x-bibtex',
+      'boo' => 'text/x-boo',
+      'h++|hpp|hxx|hh' => 'text/x-c++hdr',
+      'c++|cpp|cxx|cc' => 'text/x-c++src',
+      'h' => 'text/x-chdr',
+      'htc' => 'text/x-component',
+      'c' => 'text/x-csrc',
+      'd' => 'text/x-dsrc',
+      'diff|patch' => 'text/x-diff',
+      'hs' => 'text/x-haskell',
+      'java' => 'text/x-java',
+      'lhs' => 'text/x-literate-haskell',
+      'moc' => 'text/x-moc',
+      'p|pas' => 'text/x-pascal',
+      'gcd' => 'text/x-pcs-gcd',
+      'pl|pm' => 'text/x-perl',
+      'py' => 'text/x-python',
+      'etx' => 'text/x-setext',
+      'tcl|tk' => 'text/x-tcl',
+      'tex|ltx|sty|cls' => 'text/x-tex',
+      'vcs' => 'text/x-vcalendar',
+      'vcf' => 'text/x-vcard',
+      '3gp' => 'video/3gpp',
+      'dl' => 'video/dl',
+      'dif|dv' => 'video/dv',
+      'fli' => 'video/fli',
+      'gl' => 'video/gl',
+      'mpeg|mpg|mpe' => 'video/mpeg',
+      'mp4' => 'video/mp4',
+      'ogv' => 'video/ogg',
+      'qt|mov' => 'video/quicktime',
+      'mxu' => 'video/vnd.mpegurl',
+      'lsf|lsx' => 'video/x-la-asf',
+      'mng' => 'video/x-mng',
+      'asf|asx' => 'video/x-ms-asf',
+      'wm' => 'video/x-ms-wm',
+      'wmv' => 'video/x-ms-wmv',
+      'wmx' => 'video/x-ms-wmx',
+      'wvx' => 'video/x-ms-wvx',
+      'avi' => 'video/x-msvideo',
+      'movie' => 'video/x-sgi-movie',
+      'ice' => 'x-conference/x-cooltalk',
+      'sisx' => 'x-epoc/x-sisx-app',
+      'vrm|vrml|wrl' => 'x-world/x-vrml',
+      'xps' => 'application/vnd.ms-xpsdocument',
+    ));
+  }
+  foreach ($mapping as $ext_preg => $mime_match) {
+    if (preg_match('!\.('. $ext_preg .')$!i', $filename)) {
+      return $mime_match;
+    }
+  }
+
+  return 'application/octet-stream';
+}
diff -Naur drupal-5.0/includes/form.inc drupal-5.23/includes/form.inc
--- drupal-5.0/includes/form.inc	2007-01-15 05:09:40.000000000 +0100
+++ drupal-5.23/includes/form.inc	2009-02-26 06:50:33.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: form.inc,v 1.174 2007/01/15 04:09:40 unconed Exp $
+// $Id: form.inc,v 1.174.2.17 2009/02/26 05:50:33 drumm Exp $
 
 /**
  * @defgroup form Form generation
@@ -13,18 +13,18 @@
  * The drupal_get_form() function handles retrieving, processing, and
  * displaying a rendered HTML form for modules automatically. For example:
  *
- * // display the user registration form
+ * @code
+ * // Display the user registration form.
  * $output = drupal_get_form('user_register');
+ * @endcode
  *
  * Forms can also be built and submitted programmatically without any user input
  * using the drupal_execute() function.
  *
- *
  * For information on the format of the structured arrays used to define forms,
- * and more detailed explanations of the Form API workflow, see the reference at
- * http://api.drupal.org/api/HEAD/file/developer/topics/forms_api_reference.html
- * and the quickstart guide at
- * http://api.drupal.org/api/HEAD/file/developer/topics/forms_api.html
+ * and more detailed explanations of the Form API workflow, see the
+ * @link http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/5 reference @endlink
+ * and the @link http://api.drupal.org/api/file/developer/topics/forms_api.html/5 quickstart guide. @endlink
  */
 
 /**
@@ -59,6 +59,7 @@
     $stored = TRUE;
     $args = $_SESSION['form'][$_POST['form_build_id']]['args'];
     $form = call_user_func_array('drupal_retrieve_form', $args);
+    $form['#build_id'] = $_POST['form_build_id'];
   }
   else {
     // We're coming in fresh; build things as they would be. If the
@@ -248,7 +249,7 @@
   $form_button_counter = array(0, 0);
 
   drupal_prepare_form($form_id, $form);
-  if (($form['#programmed']) || (!empty($_POST) && (($_POST['form_id'] == $form_id) || ($_POST['form_id'] == $form['#base'])))) {
+  if (($form['#programmed']) || (!empty($_POST) && (($_POST['form_id'] == $form_id)))) {
     drupal_validate_form($form_id, $form);
     // IE does not send a button value when there is only one submit button (and no non-submit buttons)
     // and you submit by pressing enter.
@@ -309,10 +310,10 @@
     $base = $form['#base'];
   }
 
-  // Add a token, based on either #token or form_id, to any form displayed to authenticated users.
-  // This ensures that any submitted form was actually requested previously by the user and protects against
-  // cross site request forgeries.
-
+  // Add a token, based on either #token or form_id, to any form displayed to
+  // authenticated users. This ensures that any submitted form was actually
+  // requested previously by the user and protects against cross site request
+  // forgeries.
   if (isset($form['#token'])) {
     if ($form['#token'] === FALSE || $user->uid == 0 || $form['#programmed']) {
       unset($form['#token']);
@@ -351,8 +352,7 @@
 
   if (!isset($form['#submit'])) {
     if (function_exists($form_id .'_submit')) {
-      // we set submit here so that it can be altered but use reference for
-      // $form_values because it will change later
+      // We set submit here so that it can be altered.
       $form['#submit'] = array($form_id .'_submit' => array());
     }
     elseif (function_exists($base .'_submit')) {
@@ -389,10 +389,10 @@
   }
 
   // If the session token was set by drupal_prepare_form(), ensure that it
-  // matches the current user's session
+  // matches the current user's session.
   if (isset($form['#token'])) {
     if (!drupal_valid_token($form_values['form_token'], $form['#token'])) {
-      // setting this error will cause the form to fail validation
+      // Setting this error will cause the form to fail validation.
       form_set_error('form_token', t('Validation error, please try again. If this error persists, please contact the site administrator.'));
     }
   }
@@ -418,19 +418,24 @@
 function drupal_submit_form($form_id, $form) {
   global $form_values;
   $default_args = array($form_id, &$form_values);
+  $submitted = FALSE;
+  $goto = NULL;
 
   if (isset($form['#submit'])) {
     foreach ($form['#submit'] as $function => $args) {
       if (function_exists($function)) {
         $args = array_merge($default_args, (array) $args);
-        // Since we can only redirect to one page, only the last redirect will work
+        // Since we can only redirect to one page, only the last redirect
+        // will work.
         $redirect = call_user_func_array($function, $args);
+        $submitted = TRUE;
         if (isset($redirect)) {
           $goto = $redirect;
         }
       }
     }
   }
+
   return $goto;
 }
 
@@ -504,6 +509,17 @@
   }
 }
 
+/**
+ * Performs validation on form elements. First ensures required fields are
+ * completed, #maxlength is not exceeded, and selected options were in the
+ * list of options given to the user. Then calls user-defined validators.
+ *
+ * @param $elements
+ *   An associative array containing the structure of the form.
+ * @param $form_id
+ *   A unique string identifying the form for validation, submission,
+ *   theming, and hook_form_alter functions.
+ */
 function _form_validate($elements, $form_id = NULL) {
   // Recurse through all children.
   foreach (element_children($elements) as $key) {
@@ -514,10 +530,11 @@
   /* Validate the current input */
   if (!isset($elements['#validated']) || !$elements['#validated']) {
     if (isset($elements['#needs_validation'])) {
-      // An empty textfield returns '' so we use empty(). An empty checkbox
-      // and a textfield could return '0' and empty('0') returns TRUE so we
-      // need a special check for the '0' string.
-      if ($elements['#required'] && empty($elements['#value']) && $elements['#value'] !== '0') {
+      // Make sure a value is passed when the field is required.
+      // A simple call to empty() will not cut it here as some fields, like
+      // checkboxes, can return a valid value of '0'. Instead, check the
+      // length if it's a string, and the item count if it's an array.
+      if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) {
         form_error($elements, t('!name field is required.', array('!name' => $elements['#title'])));
       }
 
@@ -526,7 +543,8 @@
         form_error($elements, t('!name cannot be longer than %max characters but is currently %length characters long.', array('!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => drupal_strlen($elements['#value']))));
       }
 
-      // Add legal choice check if element has #options. Can be skipped, but then you must validate your own element.
+       // Add legal choice check if element has #options. Can be skipped, but
+       // then you must validate your own element.
       if (isset($elements['#options']) && isset($elements['#value']) && !isset($elements['#DANGEROUS_SKIP_CHECK'])) {
         if ($elements['#type'] == 'select') {
           $options = form_options_flatten($elements['#options']);
@@ -550,11 +568,11 @@
       }
     }
 
-    // User-applied checks.
+    // Call user-defined validators.
     if (isset($elements['#validate'])) {
       foreach ($elements['#validate'] as $function => $args) {
         $args = array_merge(array($elements), $args);
-        // for the full form we hand over a copy of $form_values
+        // For the full form we hand over a copy of $form_values.
         if (isset($form_id)) {
           $args = array_merge(array($form_id, $GLOBALS['form_values']), $args);
         }
@@ -618,7 +636,7 @@
 
 /**
  * Adds some required properties to each form element, which are used
- * internally in the form api. This function also automatically assigns
+ * internally in the form API. This function also automatically assigns
  * the value property from the $edit array, provided the element doesn't
  * already have an assigned value.
  *
@@ -636,7 +654,7 @@
 
   /* Use element defaults */
   if ((!empty($form['#type'])) && ($info = _element_info($form['#type']))) {
-    // overlay $info onto $form, retaining preexisting keys in $form
+    // Overlay $info onto $form, retaining preexisting keys in $form.
     $form += $info;
   }
 
@@ -645,9 +663,9 @@
       $name = array_shift($form['#parents']);
       $form['#name'] = $name;
       if ($form['#type'] == 'file') {
-        // to make it easier to handle $_FILES in file.inc, we place all
+        // To make it easier to handle $_FILES in file.inc, we place all
         // file fields in the 'files' array. Also, we do not support
-        // nested file names
+        // nested file names.
         $form['#name'] = 'files['. $form['#name'] .']';
       }
       elseif (count($form['#parents'])) {
@@ -691,7 +709,8 @@
 
             case 'textfield':
               if (isset($edit)) {
-                // Equate $edit to the form value to ensure it's marked for validation
+                // Equate $edit to the form value to ensure it's marked for
+                // validation.
                 $edit = str_replace(array("\r", "\n"), '', $edit);
                 $form['#value'] = $edit;
               }
@@ -706,7 +725,7 @@
                 $form['#value'] = $edit;
               }
           }
-          // Mark all posted values for validation
+          // Mark all posted values for validation.
           if ((isset($form['#value']) && $form['#value'] === $edit) || (isset($form['#required']) && $form['#required'])) {
             $form['#needs_validation'] = TRUE;
           }
@@ -723,21 +742,22 @@
       }
     }
     if (isset($form['#executes_submit_callback'])) {
-      // Count submit and non-submit buttons
+      // Count submit and non-submit buttons.
       $form_button_counter[$form['#executes_submit_callback']]++;
-      // See if a submit button was pressed
+      // See if a submit button was pressed.
       if (isset($form['#post'][$form['#name']]) && $form['#post'][$form['#name']] == $form['#value']) {
         $form_submitted = $form_submitted || $form['#executes_submit_callback'];
 
-        // In most cases, we want to use form_set_value() to manipulate the global variables.
-        // In this special case, we want to make sure that the value of this element is listed
-        // in $form_variables under 'op'.
+        // In most cases, we want to use form_set_value() to manipulate the
+        // global variables. In this special case, we want to make sure that
+        // the value of this element is listed in $form_variables under 'op'.
         $form_values[$form['#name']] = $form['#value'];
       }
     }
   }
 
-  // Allow for elements to expand to multiple elements, e.g. radios, checkboxes and files.
+  // Allow for elements to expand to multiple elements, e.g., radios,
+  // checkboxes and files.
   if (isset($form['#process']) && !$form['#processed']) {
     foreach ($form['#process'] as $process => $args) {
       if (function_exists($process)) {
@@ -763,28 +783,30 @@
   foreach (element_children($form) as $key) {
     $form[$key]['#post'] = $form['#post'];
     $form[$key]['#programmed'] = $form['#programmed'];
-    // don't squash an existing tree value
+    // Don't squash an existing tree value.
     if (!isset($form[$key]['#tree'])) {
       $form[$key]['#tree'] = $form['#tree'];
     }
 
-    // deny access to child elements if parent is denied
+    // Deny access to child elements if parent is denied.
     if (isset($form['#access']) && !$form['#access']) {
       $form[$key]['#access'] = FALSE;
     }
 
-    // don't squash existing parents value
+    // Don't squash existing parents value.
     if (!isset($form[$key]['#parents'])) {
-      // Check to see if a tree of child elements is present. If so, continue down the tree if required.
+      // Check to see if a tree of child elements is present. If so,
+      // continue down the tree if required.
       $form[$key]['#parents'] = $form[$key]['#tree'] && $form['#tree'] ? array_merge($form['#parents'], array($key)) : array($key);
     }
 
-    // Assign a decimal placeholder weight to preserve original array order
+    // Assign a decimal placeholder weight to preserve original array order.
     if (!isset($form[$key]['#weight'])) {
       $form[$key]['#weight'] = $count/1000;
     }
     else {
-      // If one the child elements has a weight then we will need to sort later.
+      // If one of the child elements has a weight then we will need to sort
+      // later.
       unset($form['#sorted']);
     }
     $form[$key] = form_builder($form_id, $form[$key]);
@@ -824,8 +846,8 @@
 /**
  * Helper function for form_set_value().
  *
- * We iterate of $parents and create nested arrays for them
- * in $form_values if needed. Then we insert the value in
+ * We iterate over $parents and create nested arrays for them
+ * in $form_values if needed. Then we insert the value into
  * the right array.
  */
 function _form_set_value(&$form_values, $form, $parents, $value) {
@@ -936,13 +958,13 @@
     }
     else {
       $key = (string)$key;
-      if ($value_valid && ((string)$element['#value'] === $key || ($value_is_array && in_array($key, $element['#value'])))) {
+      if ($value_valid && (!$value_is_array && (string)$element['#value'] === $key || ($value_is_array && in_array($key, $element['#value'])))) {
         $selected = ' selected="selected"';
       }
       else {
         $selected = '';
       }
-      $options .= '<option value="'. $key .'"'. $selected .'>'. check_plain($choice) .'</option>';
+      $options .= '<option value="'. check_plain($key) .'"'. $selected .'>'. check_plain($choice) .'</option>';
     }
   }
   return $options;
@@ -953,7 +975,7 @@
  * that hold the given key. Returns an array of indexes that match.
  *
  * This function is useful if you need to modify the options that are
- * already in a form element, for example, to remove choices which are
+ * already in a form element; for example, to remove choices which are
  * not valid because of additional filters imposed by another module.
  * One example might be altering the choices in a taxonomy selector.
  * To correctly handle the case of a multiple hierarchy taxonomy,
@@ -1038,7 +1060,7 @@
   $output = '<input type="radio" ';
   $output .= 'name="' . $element['#name'] .'" ';
   $output .= 'value="'. $element['#return_value'] .'" ';
-  $output .= ($element['#value'] == $element['#return_value']) ? ' checked="checked" ' : ' ';
+  $output .= (check_plain($element['#value']) == $element['#return_value']) ? ' checked="checked" ' : ' ';
   $output .= drupal_attributes($element['#attributes']) .' />';
   if (!is_null($element['#title'])) {
     $output = '<label class="option">'. $output .' '. $element['#title'] .'</label>';
@@ -1085,7 +1107,7 @@
   return theme('form_element', $element, $element['#children']);
 }
 
-/*
+/**
  * Expand a password_confirm field into two text boxes.
  */
 function expand_password_confirm($element) {
@@ -1093,11 +1115,13 @@
     '#type' => 'password',
     '#title' => t('Password'),
     '#value' => $element['#value']['pass1'],
+    '#required' => $element['#required'],
   );
   $element['pass2'] =  array(
     '#type' => 'password',
     '#title' => t('Confirm password'),
     '#value' => $element['#value']['pass2'],
+    '#required' => $element['#required'],
   );
   $element['#validate'] = array('password_confirm_validate' => array());
   $element['#tree'] = TRUE;
@@ -1151,7 +1175,7 @@
  */
 function expand_date($element) {
   // Default to current date
-  if (!isset($element['#value'])) {
+  if (empty($element['#value'])) {
     $element['#value'] = array('day' => format_date(time(), 'custom', 'j'),
                             'month' => format_date(time(), 'custom', 'n'),
                             'year' => format_date(time(), 'custom', 'Y'));
@@ -1168,7 +1192,7 @@
   asort($sort);
   $order = array_keys($sort);
 
-  // Output multi-selector for date
+  // Output multi-selector for date.
   foreach ($order as $type) {
     switch ($type) {
       case 'day':
@@ -1211,7 +1235,7 @@
 }
 
 /**
- * Helper function to load value from default value for checkboxes
+ * Helper function to load value from default value for checkboxes.
  */
 function checkboxes_value(&$form) {
   $value = array();
@@ -1241,7 +1265,19 @@
   if (count($element['#options']) > 0) {
     foreach ($element['#options'] as $key => $choice) {
       if (!isset($element[$key])) {
-        $element[$key] = array('#type' => 'radio', '#title' => $choice, '#return_value' => $key, '#default_value' => $element['#default_value'], '#attributes' => $element['#attributes'], '#parents' => $element['#parents'], '#spawned' => TRUE);
+        // Generate the parents as the autogenerator does, so we will have a
+        // unique id for each radio button.
+        $parents_for_id = array_merge($element['#parents'], array($key));
+        $element[$key] = array(
+          '#type' => 'radio',
+          '#title' => $choice,
+          '#return_value' => check_plain($key),
+          '#default_value' => $element['#default_value'],
+          '#attributes' => $element['#attributes'],
+          '#id' => form_clean_id('edit-'. implode('-', $parents_for_id)),
+          '#parents' => $element['#parents'],
+          '#spawned' => TRUE
+        );
       }
     }
   }
@@ -1407,7 +1443,7 @@
 function theme_form($element) {
   // Anonymous div to satisfy XHTML compliance.
   $action = $element['#action'] ? 'action="' . check_url($element['#action']) . '" ' : '';
-  return '<form '. $action . ' method="'. $element['#method'] .'" '. 'id="'. $element['#id'] .'"'. drupal_attributes($element['#attributes']) .">\n<div>". $element['#children'] ."\n</div></form>\n";
+  return '<form '. $action .' accept-charset="UTF-8" method="'. $element['#method'] .'" '. 'id="'. $element['#id'] .'"'. drupal_attributes($element['#attributes']) .">\n<div>". $element['#children'] ."\n</div></form>\n";
 }
 
 /**
@@ -1509,21 +1545,25 @@
  *   An associative array containing the properties of the element.
  *   Properties used: title, description, id, required
  * @param $value
- *   the form element's data
+ *   The form element's data.
  * @return
- *   a string representing the form element
+ *   A string representing the form element.
  */
 function theme_form_element($element, $value) {
-  $output  = '<div class="form-item">'."\n";
+  $output  = '<div class="form-item"';
+  if (!empty($element['#id'])) {
+    $output .= ' id="'. $element['#id'] .'-wrapper"';
+  }
+  $output .= ">\n";
   $required = !empty($element['#required']) ? '<span class="form-required" title="'. t('This field is required.') .'">*</span>' : '';
 
   if (!empty($element['#title'])) {
     $title = $element['#title'];
     if (!empty($element['#id'])) {
-      $output .= ' <label for="'. $element['#id'] .'">'. t('!title: !required', array('!title' => $title, '!required' => $required)) ."</label>\n";
+      $output .= ' <label for="'. $element['#id'] .'">'. t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
     }
     else {
-      $output .= ' <label>'. t('!title: !required', array('!title' => $title, '!required' => $required)) ."</label>\n";
+      $output .= ' <label>'. t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
     }
   }
 
@@ -1544,9 +1584,9 @@
  * Adds 'required' and 'error' classes as needed.
  *
  * @param &$element
- *   The form element
+ *   The form element.
  * @param $name
- *   Array of new class names to be added
+ *   Array of new class names to be added.
  */
 function _form_set_class(&$element, $class = array()) {
   if ($element['#required']) {
@@ -1565,9 +1605,9 @@
  * Remove invalid characters from an HTML ID attribute string.
  *
  * @param $id
- *   The ID to clean
+ *   The ID to clean.
  * @return
- *   The cleaned ID
+ *   The cleaned ID.
  */
 function form_clean_id($id = NULL) {
   $id = str_replace(array('][', '_', ' '), '-', $id);
diff -Naur drupal-5.0/includes/image.inc drupal-5.23/includes/image.inc
--- drupal-5.0/includes/image.inc	2006-12-26 15:01:41.000000000 +0100
+++ drupal-5.23/includes/image.inc	2007-12-27 09:31:24.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: image.inc,v 1.17 2006/12/26 14:01:41 dries Exp $
+// $Id: image.inc,v 1.17.2.1 2007/12/27 08:31:24 drumm Exp $
 
 /**
  * Return a list of available toolkits.
@@ -235,7 +235,7 @@
     return FALSE;
   }
 
-  $res = imageCreateTrueColor($width, $height);
+  $res = imagecreatetruecolor($width, $height);
   if ($info['extension'] == 'png') {
     $transparency = imagecolorallocatealpha($res, 0, 0, 0, 127);
     imagealphablending($res, FALSE);
@@ -243,11 +243,29 @@
     imagealphablending($res, TRUE);
     imagesavealpha($res, TRUE);
   }
-  imageCopyResampled($res, $im, 0, 0, 0, 0, $width, $height, $info['width'], $info['height']);
+  elseif ($info['extension'] == 'gif') {
+    // If we have a specific transparent color.
+    $transparency_index = imagecolortransparent($im);
+    if ($transparency_index >= 0) {
+      // Get the original image's transparent color's RGB values.
+      $transparent_color = imagecolorsforindex($im, $transparency_index);
+      // Allocate the same color in the new image resource.
+      $transparency_index = imagecolorallocate($res, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
+      // Completely fill the background of the new image with allocated color.
+      imagefill($res, 0, 0, $transparency_index);
+      // Set the background color for new image to transparent.
+      imagecolortransparent($res, $transparency_index);
+      // Find number of colors in the images palette.
+      $number_colors = imagecolorstotal($im);
+      // Convert from true color to palette to fix transparency issues.
+      imagetruecolortopalette($res, TRUE, $number_colors);
+    }
+  }
+  imagecopyresampled($res, $im, 0, 0, 0, 0, $width, $height, $info['width'], $info['height']);
   $result = image_gd_close($res, $destination, $info['extension']);
 
-  imageDestroy($res);
-  imageDestroy($im);
+  imagedestroy($res);
+  imagedestroy($im);
 
   return $result;
 }
diff -Naur drupal-5.0/includes/install.inc drupal-5.23/includes/install.inc
--- drupal-5.0/includes/install.inc	2007-01-02 06:05:38.000000000 +0100
+++ drupal-5.23/includes/install.inc	2008-10-05 03:46:57.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: install.inc,v 1.31 2007/01/02 05:05:38 drumm Exp $
+// $Id: install.inc,v 1.31.2.4 2008/10/05 01:46:57 drumm Exp $
 
 define('SCHEMA_UNINSTALLED', -1);
 define('SCHEMA_INSTALLED', 0);
@@ -33,8 +33,8 @@
  * @param $module
  *   A module name.
  * @return
- *   If the module has updates, an array of available updates. Otherwise,
- *   FALSE.
+ *   If the module has updates, an array of available updates sorted by version.
+ *   Otherwise, FALSE.
  */
 function drupal_get_schema_versions($module) {
   $updates = array();
@@ -50,6 +50,7 @@
   if (count($updates) == 0) {
     return FALSE;
   }
+  sort($updates, SORT_NUMERIC);
   return $updates;
 }
 
@@ -62,10 +63,10 @@
  *   The currently installed schema version.
  */
 function drupal_get_installed_schema_version($module, $reset = FALSE) {
-  static $versions;
+  static $versions = array();
 
   if ($reset) {
-    unset($versions);
+    $versions = array();
   }
 
   if (!$versions) {
@@ -243,7 +244,7 @@
 function drupal_get_install_files($module_list = array()) {
   $installs = array();
   foreach ($module_list as $module) {
-    $installs = array_merge($installs, file_scan_directory('./modules', "^$module.install$", array('.', '..', 'CVS'), 0, TRUE, 'name', 0));
+    $installs = array_merge($installs, drupal_system_listing($module .'.install$', 'modules'));
   }
   return $installs;
 }
@@ -571,6 +572,7 @@
 function install_goto($path) {
   global $base_url;
   header('Location: '. $base_url . '/' . $path);
+  header('Cache-Control: no-cache'); // Not a permanent redirect.
   exit();
 }
 
@@ -676,6 +678,7 @@
  */
 function drupal_check_profile($profile) {
   include_once './includes/file.inc';
+  include_once './includes/common.inc';
 
   $profile_file = "./profiles/$profile/$profile.profile";
 
diff -Naur drupal-5.0/includes/locale.inc drupal-5.23/includes/locale.inc
--- drupal-5.0/includes/locale.inc	2007-01-05 06:32:22.000000000 +0100
+++ drupal-5.23/includes/locale.inc	2010-03-04 01:16:02.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: locale.inc,v 1.105 2007/01/05 05:32:22 unconed Exp $
+// $Id: locale.inc,v 1.105.2.6 2010/03/04 00:16:02 drumm Exp $
 
 /**
  * @file
@@ -41,6 +41,9 @@
   $options = array();
   $form['name'] = array('#tree' => TRUE);
   foreach ($languages['name'] as $key => $lang) {
+    // Language code should contain no markup, but is emitted
+    // by radio and checkbox options.
+    $key = check_plain($key);
     $options[$key] = '';
     $status = db_fetch_object(db_query("SELECT isdefault, enabled FROM {locales_meta} WHERE locale = '%s'", $key));
     if ($status->enabled) {
@@ -97,6 +100,14 @@
   return $output;
 }
 
+function _locale_admin_manage_screen_validate($form_id, $form_values) {
+  foreach ($form_values['name'] as $key => $value) {
+    if (preg_match('/["<>\']/', $value)) {
+      form_set_error('name][' . $key, t('The characters &lt;, &gt;, " and \' are not allowed in the language name in English field.'));
+    }
+  }
+}
+
 /**
  * Process locale admin manager form submissions.
  */
@@ -184,12 +195,22 @@
     form_set_error(t('The language %language (%code) already exists.', array('%language' => $form_values['langname'], '%code' => $form_values['langcode'])));
   }
 
+  // If we are adding a non-custom language, check for a valid langcode.
   if (!isset($form_values['langname'])) {
     $isocodes = _locale_get_iso639_list();
     if (!isset($isocodes[$form_values['langcode']])) {
       form_set_error('langcode', t('Invalid language code.'));
     }
   }
+  // Otherwise, check for invlaid characters
+  else {
+    if (preg_match('/["<>\']/', $form_values['langcode'])) {
+      form_set_error('langcode', t('The characters &lt;, &gt;, " and \' are not allowed in the language code field.'));
+    }
+    if (preg_match('/["<>\']/', $form_values['langname'])) {
+      form_set_error('langname', t('The characters &lt;, &gt;, " and \' are not allowed in the language name in English field.'));
+    }
+  }
 }
 
 /**
@@ -331,8 +352,14 @@
 function _locale_string_seek_form() {
   // Get *all* languages set up
   $languages = locale_supported_languages(FALSE, TRUE);
-  asort($languages['name']); unset($languages['name']['en']);
-  $languages['name'] = array_map('check_plain', $languages['name']);
+  unset($languages['name']['en']);
+  // Sanitize the values to be used in radios.
+  $languages_name = array();
+  foreach ($languages['name'] as $key => $value) {
+    $languages_name[check_plain($key)] = check_plain($value);
+  }
+  $languages['name'] = $languages_name;
+  asort($languages['name']);
 
   // Present edit form preserving previous user settings
   $query = _locale_string_seek_query();
@@ -526,6 +553,10 @@
 
   while (!feof($fd)) {
     $line = fgets($fd, 10*1024); // A line should not be this long
+    if ($lineno == 0) {
+      // The first line might come with a UTF-8 BOM, which should be removed.
+      $line = str_replace("\xEF\xBB\xBF", '', $line);
+    }
     $lineno++;
     $line = trim(strtr($line, array("\\\n" => "")));
 
@@ -534,7 +565,7 @@
         $current["#"][] = substr($line, 1);
       }
       elseif (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one
-        _locale_import_one_string($op, $current, $mode, $lang);
+        _locale_import_one_string($op, $current, $mode, $lang, $file);
         $current = array();
         $current["#"][] = substr($line, 1);
         $context = "COMMENT";
@@ -560,7 +591,7 @@
     }
     elseif (!strncmp("msgid", $line, 5)) {
       if ($context == "MSGSTR") {   // End current entry, start a new one
-        _locale_import_one_string($op, $current, $mode, $lang);
+        _locale_import_one_string($op, $current, $mode, $lang, $file);
         $current = array();
       }
       elseif ($context == "MSGID") { // Already in this context? Parse error
@@ -634,7 +665,7 @@
 
   // End of PO file, flush last entry
   if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) {
-    _locale_import_one_string($op, $current, $mode, $lang);
+    _locale_import_one_string($op, $current, $mode, $lang, $file);
   }
   elseif ($context != "COMMENT") {
     _locale_import_message('The translation file %filename ended unexpectedly at line %line.', $file, $lineno);
@@ -673,8 +704,10 @@
  *   Should existing translations be replaced ('overwrite' or 'keep')
  * @param $lang
  *   Language to store the string in
+ * @param $file
+ *   Object representation of file being imported, only required when op is 'db-store'
  */
-function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NULL) {
+function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NULL, $file = NULL) {
   static $additions = 0;
   static $updates = 0;
   static $headerdone = FALSE;
@@ -729,7 +762,7 @@
               $plid = 0;
             }
             $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s'", $english[$key]));
-            if ($loc->lid) { // a string exists
+            if (!empty($loc->lid)) { // a string exists
               $lid = $loc->lid;
               // update location field
               db_query("UPDATE {locales_source} SET location = '%s' WHERE lid = %d", $comments, $lid);
@@ -766,7 +799,7 @@
           $english = $value['msgid'];
           $translation = $value['msgstr'];
           $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s'", $english));
-          if ($loc->lid) { // a string exists
+          if (!empty($loc->lid)) { // a string exists
             $lid = $loc->lid;
             // update location field
             db_query("UPDATE {locales_source} SET location = '%s' WHERE source = '%s'", $comments, $english);
@@ -806,8 +839,10 @@
 /**
  * Parses a Gettext Portable Object file header
  *
- * @param $header A string containing the complete header
- * @return An associative array of key-value pairs
+ * @param $header
+ *   A string containing the complete header
+ * @return
+ *   An associative array of key-value pairs
  */
 function _locale_import_parse_header($header) {
   $hdr = array();
@@ -873,8 +908,10 @@
  * While parsing, we ensure, that the operators have the right
  * precedence and associativity.
  *
- * @param $string A string containing the arithmetic formula
- * @return The PHP version of the formula
+ * @param $string
+ *   A string containing the arithmetic formula
+ * @return
+ *   The PHP version of the formula
  */
 function _locale_import_parse_arithmetic($string) {
   // Operator precedence table
@@ -908,7 +945,7 @@
         $topop = array_pop($opstk);
       }
     }
-    elseif ($prec[$ctok]) {
+    elseif (!empty($prec[$ctok])) {
       // If it's an operator, then pop from $oparr into $elarr until the
       // precedence in $oparr is less than current, then push into $oparr
       $topop = array_pop($opstk);
@@ -968,8 +1005,10 @@
 /**
  * Backward compatible implementation of token_get_all() for formula parsing
  *
- * @param $string A string containing the arithmetic formula
- * @return The PHP version of the formula
+ * @param $string
+ *   A string containing the arithmetic formula
+ * @return
+ *   The PHP version of the formula
  */
 function _locale_import_tokenize_formula($formula) {
   $formula = str_replace(" ", "", $formula);
@@ -1032,8 +1071,10 @@
  *
  * This is a callback function used via array_map()
  *
- * @param $entry An array element
- * @param $key Index of the array element
+ * @param $entry
+ *   An array element
+ * @param $key
+ *   Index of the array element
  */
 function _locale_import_append_plural($entry, $key) {
   // No modifications for 0, 1
@@ -1049,8 +1090,10 @@
 /**
  * Generate a short, one string version of the passed comment array
  *
- * @param $comment An array of strings containing a comment
- * @return Short one string version of the comment
+ * @param $comment
+ *   An array of strings containing a comment
+ * @return
+ *   Short one string version of the comment
  */
 function _locale_import_shorten_comments($comment) {
   $comm = '';
@@ -1069,8 +1112,10 @@
 /**
  * Parses a string in quotes
  *
- * @param $string A string specified with enclosing quotes
- * @return The string parsed from inside the quotes
+ * @param $string
+ *   A string specified with enclosing quotes
+ * @return
+ *   The string parsed from inside the quotes
  */
 function _locale_import_parse_quoted($string) {
   if (substr($string, 0, 1) != substr($string, -1, 1)) {
@@ -1544,7 +1589,8 @@
     "ne" => array("Nepali"),
     "ng" => array("Ndonga"),
     "nl" => array("Dutch", "Nederlands"),
-    "no" => array("Norwegian", "Norsk"),
+    "nb" => array("Norwegian BokmÃ¥l", "BokmÃ¥l"),
+    "nn" => array("Norwegian Nynorsk", "Nynorsk"),
     "nr" => array("South Ndebele"),
     "nv" => array("Navajo"),
     "ny" => array("Chichewa"),
diff -Naur drupal-5.0/includes/menu.inc drupal-5.23/includes/menu.inc
--- drupal-5.0/includes/menu.inc	2007-01-14 02:37:48.000000000 +0100
+++ drupal-5.23/includes/menu.inc	2009-07-10 07:56:51.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: menu.inc,v 1.146 2007/01/14 01:37:48 unconed Exp $
+// $Id: menu.inc,v 1.146.2.3 2009/07/10 05:56:51 drumm Exp $
 
 /**
  * @file
@@ -396,7 +396,7 @@
     $path = substr($path, 0, strrpos($path, '/'));
   }
 
-  if (!isset($menu['callbacks'][$path])) {
+  if ($path === '' || !isset($menu['callbacks'][$path])) {
     return MENU_NOT_FOUND;
   }
 
@@ -975,7 +975,7 @@
     $count = 0;
     while ($path && !$count) {
       foreach ($menu['items'] as $key => $item) {
-        if (isset($item['path']) && $item['path'] == $path) {
+        if (isset($item['path']) && ($item['path'] == $path || ($item['path'] == '<front>' && drupal_is_front_page()))) {
           $trails[$count] = array();
           $mid = $key;
           while ($mid && $menu['items'][$mid]) {
@@ -1055,6 +1055,10 @@
   $temp_mid = -1;
 
   foreach ($menu_item_list as $item) {
+    // Protect against D6 style access
+    if (isset($item['access']) && is_array($item['access']) && count($item['access']) == 1 && isset($item['access'][0]) && is_string($item['access'][0])) {
+      $item['access'] = FALSE;
+    }
     if (!isset($item['path'])) {
       $item['path'] = '';
     }
@@ -1225,6 +1229,10 @@
   $new_items = array();
 
   foreach ($menu_item_list as $item) {
+    // Protect against D6 style access
+    if (isset($item['access']) && is_array($item['access']) && count($item['access']) == 1 && isset($item['access'][0]) && is_string($item['access'][0])) {
+      $item['access'] = FALSE;
+    }
     if (isset($item['callback'])) {
       $_menu['callbacks'][$item['path']] = array('callback' => $item['callback']);
       if (isset($item['callback arguments'])) {
diff -Naur drupal-5.0/includes/module.inc drupal-5.23/includes/module.inc
--- drupal-5.0/includes/module.inc	2006-12-07 18:03:34.000000000 +0100
+++ drupal-5.23/includes/module.inc	2007-07-21 02:54:18.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: module.inc,v 1.93 2006/12/07 17:03:34 dries Exp $
+// $Id: module.inc,v 1.93.2.2 2007/07/21 00:54:18 drumm Exp $
 
 /**
  * @file
@@ -58,10 +58,10 @@
     }
     else {
       if ($bootstrap) {
-        $result = db_query("SELECT name, filename, throttle, bootstrap FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, filename ASC");
+        $result = db_query("SELECT name, filename, throttle FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, filename ASC");
       }
       else {
-        $result = db_query("SELECT name, filename, throttle, bootstrap FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
+        $result = db_query("SELECT name, filename, throttle FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
       }
       while ($module = db_fetch_object($result)) {
         if (file_exists($module->filename)) {
@@ -239,7 +239,7 @@
 function module_enable($module_list) {
   $invoke_modules = array();
   foreach ($module_list as $module) {
-    $existing = db_fetch_object(db_query("SELECT name, status FROM {system} WHERE type = 'module' AND name = '%s'", $module));
+    $existing = db_fetch_object(db_query("SELECT status FROM {system} WHERE type = 'module' AND name = '%s'", $module));
     if ($existing->status === '0') {
       module_load_install($module);
       db_query("UPDATE {system} SET status = 1, throttle = 0 WHERE type = 'module' AND name = '%s'", $module);
@@ -342,7 +342,7 @@
   static $implementations;
 
   if ($refresh) {
-    unset($implementations);
+    $implementations = array();
     return;
   }
 
diff -Naur drupal-5.0/includes/pager.inc drupal-5.23/includes/pager.inc
--- drupal-5.0/includes/pager.inc	2006-10-15 21:57:05.000000000 +0200
+++ drupal-5.23/includes/pager.inc	2009-07-01 22:52:11.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: pager.inc,v 1.59 2006/10/15 19:57:05 dries Exp $
+// $Id: pager.inc,v 1.59.2.1 2009/07/01 20:52:11 drumm Exp $
 
 /**
  * @file
@@ -85,7 +85,7 @@
 function pager_get_querystring() {
   static $string = NULL;
   if (!isset($string)) {
-    $string = drupal_query_string_encode($_REQUEST, array_merge(array('q', 'page'), array_keys($_COOKIE)));
+    $string = drupal_query_string_encode($_REQUEST, array_merge(array('q', 'page', 'pass'), array_keys($_COOKIE)));
   }
   return $string;
 }
diff -Naur drupal-5.0/includes/session.inc drupal-5.23/includes/session.inc
--- drupal-5.0/includes/session.inc	2006-12-04 11:41:19.000000000 +0100
+++ drupal-5.23/includes/session.inc	2010-03-04 01:16:02.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: session.inc,v 1.37 2006/12/04 10:41:19 dries Exp $
+// $Id: session.inc,v 1.37.2.8 2010/03/04 00:16:02 drumm Exp $
 
 /**
  * @file
@@ -31,8 +31,9 @@
   // Otherwise, if the session is still active, we have a record of the client's session in the database.
   $user = db_fetch_object(db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '%s'", $key));
 
-  // We found the client's session record and they are an authenticated user
-  if ($user && $user->uid > 0) {
+  // We found the client's session record and they are an authenticated,
+  // active user.
+  if ($user && $user->uid > 0 && $user->status == 1) {
     // This is done to unserialize the data member of $user
     $user = drupal_unpack($user);
 
@@ -44,8 +45,9 @@
       $user->roles[$role->rid] = $role->name;
     }
   }
-  // We didn't find the client's record (session has expired), or they are an anonymous user.
-  else  {
+  // We didn't find the client's record (session has expired), or they are
+  // blocked, or they are an anonymous user.
+  else {
     $session = isset($user->session) ? $user->session : '';
     $user = drupal_anonymous_user($session);
   }
@@ -56,31 +58,27 @@
 function sess_write($key, $value) {
   global $user;
 
-  // If the client doesn't have a session, and one isn't being created ($value), do nothing.
-  if (empty($_COOKIE[session_name()]) && empty($value)) {
+  // If saving of session data is disabled or if the client doesn't have a session,
+  // and one isn't being created ($value), do nothing. This keeps crawlers out of
+  // the session table. This reduces memory and server load, and gives more useful
+  // statistics. We can't eliminate anonymous session table rows without breaking
+  // the throttle module and the "Who's Online" block.
+  if (!session_save_session() || ($user->uid == 0 && empty($_COOKIE[session_name()]) && empty($value))) {
     return TRUE;
   }
 
-  $result = db_query("SELECT sid FROM {sessions} WHERE sid = '%s'", $key);
-
-  if (!db_num_rows($result)) {
-    // Only save session data when when the browser sends a cookie. This keeps
-    // crawlers out of session table. This improves speed up queries, reduces
-    // memory, and gives more useful statistics. We can't eliminate anonymous
-    // session table rows without breaking throttle module and "Who's Online"
-    // block.
-    if ($user->uid || $value || count($_COOKIE)) {
-      db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, $user->cache, $_SERVER["REMOTE_ADDR"], $value, time());
-    }
-  }
-  else {
-    db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, $user->cache, $_SERVER["REMOTE_ADDR"], $value, time(), $key);
-
+  db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : '', $_SERVER["REMOTE_ADDR"], $value, time(), $key);
+  if (db_affected_rows()) {
     // TODO: this can be an expensive query. Perhaps only execute it every x minutes. Requires investigation into cache expiration.
     if ($user->uid) {
       db_query("UPDATE {users} SET access = %d WHERE uid = %d", time(), $user->uid);
     }
   }
+  else {
+    // If this query fails, another parallel request probably got here first.
+    // In that case, any session data generated in this request is discarded.
+    @db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, isset($user->cache) ? $user->cache : '', $_SERVER["REMOTE_ADDR"], $value, time());
+  }
 
   return TRUE;
 }
@@ -153,3 +151,23 @@
 
   return TRUE;
 }
+
+/**
+ * Determine whether to save session data of the current request.
+ *
+ * This function allows the caller to temporarily disable writing of session data,
+ * should the request end while performing potentially dangerous operations, such as
+ * manipulating the global $user object.
+ *
+ * @param $status
+ *   Disables writing of session data when FALSE, (re-)enables writing when TRUE.
+ * @return
+ *   FALSE if writing session data has been disabled. Otherwise, TRUE.
+ */
+function session_save_session($status = NULL) {
+  static $save_session = TRUE;
+  if (isset($status)) {
+    $save_session = $status;
+  }
+  return ($save_session);
+}
diff -Naur drupal-5.0/includes/tablesort.inc drupal-5.23/includes/tablesort.inc
--- drupal-5.0/includes/tablesort.inc	2006-12-01 09:50:33.000000000 +0100
+++ drupal-5.23/includes/tablesort.inc	2009-07-01 22:52:11.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: tablesort.inc,v 1.43 2006/12/01 08:50:33 dries Exp $
+// $Id: tablesort.inc,v 1.43.2.2 2009/07/01 20:52:11 drumm Exp $
 
 /**
  * @file
@@ -131,7 +131,7 @@
  *   except for those pertaining to table sorting.
  */
 function tablesort_get_querystring() {
-  return drupal_query_string_encode($_REQUEST, array_merge(array('q', 'sort', 'order'), array_keys($_COOKIE)));
+  return drupal_query_string_encode($_REQUEST, array_merge(array('q', 'sort', 'order', 'pass'), array_keys($_COOKIE)));
 }
 
 /**
@@ -148,11 +148,11 @@
   $order = isset($_GET['order']) ? $_GET['order'] : '';
   foreach ($headers as $header) {
     if (isset($header['data']) && $order == $header['data']) {
-      return array('name' => $header['data'], 'sql' => $header['field']);
+      return array('name' => $header['data'], 'sql' => isset($header['field']) ? $header['field'] : '');
     }
 
     if (isset($header['sort']) && ($header['sort'] == 'asc' || $header['sort'] == 'desc')) {
-      $default = array('name' => $header['data'], 'sql' => $header['field']);
+      $default = array('name' => $header['data'], 'sql' => isset($header['field']) ? $header['field'] : '');
     }
   }
 
diff -Naur drupal-5.0/includes/theme.inc drupal-5.23/includes/theme.inc
--- drupal-5.0/includes/theme.inc	2007-01-11 04:36:06.000000000 +0100
+++ drupal-5.23/includes/theme.inc	2009-05-13 21:41:56.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: theme.inc,v 1.337 2007/01/11 03:36:06 unconed Exp $
+// $Id: theme.inc,v 1.337.2.9 2009/05/13 19:41:56 drumm Exp $
 
 /**
  * @file
@@ -8,7 +8,7 @@
  * The theme system allows for nearly all output of the Drupal system to be
  * customized by user themes.
  *
- * @see <a href="http://drupal.org/node/253">Theme system</a>
+ * @see <a href="http://drupal.org/node/171179">Theme guide</a>
  * @see themeable
  */
 
@@ -42,7 +42,8 @@
 
   // Only select the user selected theme if it is available in the
   // list of enabled themes.
-  $theme = $user->theme && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'garland');
+  $theme = !empty($user->theme) && !empty($themes[$user->theme]->status) ? $user->theme : variable_get('theme_default', 'garland');
+
 
   // Allow modules to override the present theme... only select custom theme
   // if it is available in the list of installed themes.
@@ -167,7 +168,12 @@
     $functions[$function] = theme_get_function($function);
   }
   if ($functions[$function]) {
-    return call_user_func_array($functions[$function], $args);
+    $output = call_user_func_array($functions[$function], $args);
+    // Add final markup to the full page.
+    if ($function == 'page' || $function == 'book_export_html') {
+      $output = drupal_final_markup($output);
+    }
+    return $output;
   }
 }
 
@@ -341,6 +347,9 @@
       elseif ($settings['favicon_path']) {
         $settings['favicon'] = base_path() . $settings['favicon_path'];
       }
+      else {
+        $settings['toggle_favicon'] = FALSE;
+      }
     }
   }
 
@@ -541,16 +550,14 @@
     $i = 1;
 
     foreach ($links as $key => $link) {
-      $class = '';
+      $class = $key;
 
       // Automatically add a class to each link and also to each LI
       if (isset($link['attributes']) && isset($link['attributes']['class'])) {
         $link['attributes']['class'] .= ' ' . $key;
-        $class = $key;
       }
       else {
         $link['attributes']['class'] = $key;
-        $class = $key;
       }
 
       // Add first and last classes to the list of links to help out themers.
@@ -561,7 +568,7 @@
       if ($i == $num_links) {
         $extra_class .= 'last ';
       }
-      $output .= '<li class="'. $extra_class . $class .'">';
+      $output .= '<li '. drupal_attributes(array('class' => $extra_class . $class)) .'>';
 
       // Is the title HTML?
       $html = isset($link['html']) && $link['html'];
@@ -762,17 +769,22 @@
   // Format the table header:
   if (count($header)) {
     $ts = tablesort_init($header);
-    $output .= ' <thead><tr>';
+    // HTML requires that the thead tag has tr tags in it follwed by tbody
+    // tags. Using ternary operator to check and see if we have any rows.
+    $output .= (count($rows) ? ' <thead><tr>' : ' <tr>');
     foreach ($header as $cell) {
       $cell = tablesort_header($cell, $header, $ts);
       $output .= _theme_table_cell($cell, TRUE);
     }
-    $output .= " </tr></thead>\n";
+    // Using ternary operator to close the tags based on whether or not there are rows
+    $output .= (count($rows) ? " </tr></thead>\n" : "</tr>\n");
   }
 
   // Format the table rows:
-  $output .= "<tbody>\n";
   if (count($rows)) {
+    $output .= "<tbody>\n";
+    $flip = array('even' => 'odd', 'odd' => 'even');
+    $class = 'even';
     foreach ($rows as $number => $row) {
       $attributes = array();
 
@@ -792,7 +804,7 @@
       }
 
       // Add odd/even class
-      $class = ($number % 2 == 1) ? 'even': 'odd';
+      $class = $flip[$class];
       if (isset($attributes['class'])) {
         $attributes['class'] .= ' '. $class;
       }
@@ -809,9 +821,10 @@
       }
       $output .= " </tr>\n";
     }
+    $output .= "</tbody>\n";
   }
 
-  $output .= "</tbody></table>\n";
+  $output .= "</table>\n";
   return $output;
 }
 
@@ -915,10 +928,10 @@
  *   All other elements are treated as attributes of the list item element.
  * @param $title
  *   The title of the list.
- * @param $attributes
- *   The attributes applied to the list element.
  * @param $type
  *   The type of list to return (e.g. "ul", "ol")
+ * @param $attributes
+ *   The attributes applied to the list element.
  * @return
  *   A string containing the list output.
  */
diff -Naur drupal-5.0/includes/unicode.inc drupal-5.23/includes/unicode.inc
--- drupal-5.0/includes/unicode.inc	2006-12-06 17:15:52.000000000 +0100
+++ drupal-5.23/includes/unicode.inc	2007-05-21 03:09:21.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: unicode.inc,v 1.23 2006/12/06 16:15:52 dries Exp $
+// $Id: unicode.inc,v 1.23.2.2 2007/05/21 01:09:21 drumm Exp $
 
 /**
  * Indicates an error during check for PHP unicode support.
@@ -78,7 +78,7 @@
  */
 function unicode_requirements() {
   // Ensure translations don't break at install time
-  $t = function_exists('install_main') ? 'st' : 't';
+  $t = get_t();
 
   $libraries = array(
     UNICODE_SINGLEBYTE => $t('Standard PHP'),
@@ -441,6 +441,7 @@
   else {
     $strlen = strlen($text);
     // Find the starting byte offset
+    $bytes = 0;
     if ($start > 0) {
       // Count all the continuation bytes from the start until we have found
       // $start characters
diff -Naur drupal-5.0/includes/xmlrpc.inc drupal-5.23/includes/xmlrpc.inc
--- drupal-5.0/includes/xmlrpc.inc	2006-09-03 10:21:18.000000000 +0200
+++ drupal-5.23/includes/xmlrpc.inc	2008-10-02 00:01:17.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: xmlrpc.inc,v 1.38 2006/09/03 08:21:18 dries Exp $
+// $Id: xmlrpc.inc,v 1.38.2.5 2008/10/01 22:01:17 drumm Exp $
 
 /*
   Drupal XML-RPC library. Based on the IXR - The Incutio XML-RPC Library - (c) Incutio Ltd 2002-2005
@@ -343,7 +343,7 @@
 }
 
 
-function xmlrpc_error($code = NULL, $message = NULL) {
+function xmlrpc_error($code = NULL, $message = NULL, $reset = FALSE) {
   static $xmlrpc_error;
   if (isset($code)) {
     $xmlrpc_error = new stdClass();
@@ -351,6 +351,9 @@
     $xmlrpc_error->code = $code;
     $xmlrpc_error->message = $message;
   }
+  elseif ($reset) {
+    $xmlrpc_error = NULL;
+  }
   return $xmlrpc_error;
 }
 
@@ -387,15 +390,16 @@
     $xmlrpc_date->hour = date('H', $time);
     $xmlrpc_date->minute = date('i', $time);
     $xmlrpc_date->second = date('s', $time);
-    $xmlrpc_date->iso8601 = date('Ymd\TH:i:s');
+    $xmlrpc_date->iso8601 = date('Ymd\TH:i:s', $time);
   }
   else {
+    $time = str_replace(array('-', ':'), '', $time);
     $xmlrpc_date->year = substr($time, 0, 4);
     $xmlrpc_date->month = substr($time, 4, 2);
     $xmlrpc_date->day = substr($time, 6, 2);
     $xmlrpc_date->hour = substr($time, 9, 2);
-    $xmlrpc_date->minute = substr($time, 12, 2);
-    $xmlrpc_date->second = substr($time, 15, 2);
+    $xmlrpc_date->minute = substr($time, 11, 2);
+    $xmlrpc_date->second = substr($time, 13, 2);
     $xmlrpc_date->iso8601 = $time;
   }
   return $xmlrpc_date;
@@ -426,6 +430,7 @@
 function _xmlrpc() {
   $args = func_get_args();
   $url = array_shift($args);
+  xmlrpc_clear_error();
   if (is_array($args[0])) {
     $method = 'system.multicall';
     $multicall_args = array();
@@ -440,7 +445,7 @@
   $xmlrpc_request = xmlrpc_request($method, $args);
   $result = drupal_http_request($url, array("Content-Type" => "text/xml"), 'POST', $xmlrpc_request->xml);
   if ($result->code != 200) {
-    xmlrpc_error(-$result->code, $result->error);
+    xmlrpc_error($result->code, $result->error);
     return FALSE;
   }
   $message = xmlrpc_message($result->data);
@@ -474,3 +479,10 @@
   $error = xmlrpc_error();
   return $error->message;
 }
+
+/**
+ * Clears any previous error.
+ */
+function xmlrpc_clear_error() {
+  xmlrpc_error(NULL, NULL, TRUE);
+}
\ No newline at end of file
diff -Naur drupal-5.0/includes/xmlrpcs.inc drupal-5.23/includes/xmlrpcs.inc
--- drupal-5.0/includes/xmlrpcs.inc	2006-07-05 13:45:51.000000000 +0200
+++ drupal-5.23/includes/xmlrpcs.inc	2008-05-10 03:53:33.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: xmlrpcs.inc,v 1.21 2006/07/05 11:45:51 dries Exp $
+// $Id: xmlrpcs.inc,v 1.21.2.1 2008/05/10 01:53:33 drumm Exp $
 
 /**
  * The main entry point for XML-RPC requests.
@@ -149,7 +149,7 @@
   }
   // Has this method been mapped to a Drupal function by us or by modules?
   if (!isset($xmlrpc_server->callbacks[$methodname])) {
-    return xmlrpc_error(-32601, t('Server error. Requested method %methodname not specified.', array("%methodname" => $xmlrpc_server->message->methodname)));
+    return xmlrpc_error(-32601, t('Server error. Requested method @methodname not specified.', array("@methodname" => $xmlrpc_server->message->methodname)));
   }
   $method = $xmlrpc_server->callbacks[$methodname];
   $signature = $xmlrpc_server->signatures[$methodname];
@@ -208,7 +208,7 @@
   }
   */
   if (!function_exists($method)) {
-    return xmlrpc_error(-32601, t('Server error. Requested function %method does not exist.', array("%method" => $method)));
+    return xmlrpc_error(-32601, t('Server error. Requested function @method does not exist.', array("@method" => $method)));
   }
   // Call the mapped function
   return call_user_func_array($method, $args);
@@ -293,10 +293,10 @@
 function xmlrpc_server_method_signature($methodname) {
   $xmlrpc_server = xmlrpc_server_get();
   if (!isset($xmlrpc_server->callbacks[$methodname])) {
-    return xmlrpc_error(-32601, t('Server error. Requested method %methodname not specified.', array("%methodname" => $methodname)));
+    return xmlrpc_error(-32601, t('Server error. Requested method @methodname not specified.', array("@methodname" => $methodname)));
   }
   if (!is_array($xmlrpc_server->signatures[$methodname])) {
-    return xmlrpc_error(-32601, t('Server error. Requested method %methodname signature not specified.', array("%methodname" => $methodname)));
+    return xmlrpc_error(-32601, t('Server error. Requested method @methodname signature not specified.', array("@methodname" => $methodname)));
   }
   // We array of types
   $return = array();
@@ -315,4 +315,4 @@
 function xmlrpc_server_method_help($method) {
   $xmlrpc_server = xmlrpc_server_get();
   return $xmlrpc_server->help[$method];
-}
\ No newline at end of file
+}
diff -Naur drupal-5.0/install.php drupal-5.23/install.php
--- drupal-5.0/install.php	2007-01-10 11:15:07.000000000 +0100
+++ drupal-5.23/install.php	2008-07-09 23:48:41.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: install.php,v 1.34 2007/01/10 10:15:07 unconed Exp $
+// $Id: install.php,v 1.34.2.5 2008/07/09 21:48:41 drumm Exp $
 
 require_once './includes/install.inc';
 
@@ -15,9 +15,10 @@
  *   The installation phase we should proceed to.
  */
 function install_main() {
-  global $profile, $install_locale;
   require_once './includes/bootstrap.inc';
   drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
+  // This must go after drupal_bootstrap(), which unsets globals!
+  global $profile, $install_locale;
   require_once './modules/system/system.install';
   require_once './includes/file.inc';
 
@@ -152,6 +153,15 @@
   include_once './includes/form.inc';
   drupal_maintenance_theme();
 
+  // Don't fill in placeholders
+  if ($db_url == 'mysql://username:password@localhost/databasename') {
+    $db_user = $db_pass = $db_path = '';
+  }
+  elseif (!empty($db_url)) {
+    // Do not install over a configured settings.php.
+    install_already_done_error();
+  }
+
   // The existing database settings are not working, so we need write access
   // to settings.php to change them.
   if (!drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_WRITABLE)) {
@@ -162,10 +172,6 @@
     exit;
   }
 
-  // Don't fill in placeholders
-  if ($db_url == 'mysql://username:password@localhost/databasename') {
-    $db_user = $db_pass = $db_path = '';
-  }
   $output = drupal_get_form('install_settings_form', $profile, $install_locale, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host, $db_port, $db_path);
   drupal_set_title(st('Database configuration'));
   print theme('install_page', $output);
@@ -316,8 +322,8 @@
   }
 
   // Verify the table prefix
-  if (!empty($db_prefix) && is_string($db_prefix) && !preg_match('/^[A-Za-z0-9_.]+$/', $db_prefix)) {
-    form_set_error('db_prefix', st('The database table prefix you have entered, %db_prefix, is invalid. The table prefix can only contain alphanumeric characters, underscores or dots.', array('%db_prefix' => $db_prefix)), 'error');
+  if (!empty($db_prefix) && is_string($db_prefix) && !preg_match('/^[A-Za-z0-9_]+$/', $db_prefix)) {
+    form_set_error('db_prefix', st('The database table prefix you have entered, %db_prefix, is invalid. The table prefix can only contain alphanumeric characters or underscores.', array('%db_prefix' => $db_prefix)), 'error');
   }
 
   if (!empty($db_port) && !is_numeric($db_port)) {
@@ -506,7 +512,7 @@
 
   drupal_maintenance_theme();
   drupal_set_title(st('Drupal already installed'));
-  print theme('install_page', st('<ul><li>To start over, you must empty your existing database.</li><li>To install to a different database, edit the appropriate <em>settings.php</em> file in the <em>sites</em> folder.</li><li>To upgrade an existing installation, proceed to the <a href="@base-url/update.php">update script</a>.</li></ul>', array('@base-url' => $base_url)));
+  print theme('install_page', st('<ul><li>To start over, you must empty your existing database and replace the appropriate <em>settings.php</em> with an unmodified copy.</li><li>To install to a different database, edit the appropriate <em>settings.php</em> file in the <em>sites</em> folder.</li><li>To upgrade an existing installation, proceed to the <a href="@base-url/update.php">update script</a>.</li></ul>', array('@base-url' => $base_url)));
   exit;
 }
 
@@ -527,6 +533,7 @@
  */
 function install_complete($profile) {
   global $base_url;
+  $output = '';
   // Store install profile for later use.
   variable_set('install_profile', $profile);
 
diff -Naur drupal-5.0/misc/drupal.js drupal-5.23/misc/drupal.js
--- drupal-5.0/misc/drupal.js	2006-10-14 04:39:48.000000000 +0200
+++ drupal-5.23/misc/drupal.js	2009-02-26 07:46:48.000000000 +0100
@@ -1,4 +1,4 @@
-// $Id: drupal.js,v 1.29 2006/10/14 02:39:48 unconed Exp $
+// $Id: drupal.js,v 1.29.2.3 2009/02/26 06:46:48 drumm Exp $
 
 var Drupal = Drupal || {};
 
@@ -12,8 +12,8 @@
  */
 Drupal.extend = function(obj) {
   for (var i in obj) {
-    if (this[i]) {
-      Drupal.extend.apply(this[i], [obj[i]]);
+    if (this[i] && (typeof(this[i]) == 'function' || typeof(this[i]) == 'object')) {
+   	  Drupal.extend.apply(this[i], [obj[i]]);
     }
     else {
       this[i] = obj[i];
@@ -196,11 +196,11 @@
  */
 Drupal.encodeURIComponent = function (item, uri) {
   uri = uri || location.href;
-  item = encodeURIComponent(item).replace('%2F', '/');
-  return uri.indexOf('?q=') ? item : item.replace('%26', '%2526').replace('%23', '%2523');
+  item = encodeURIComponent(item).replace(/%2F/g, '/');
+  return (uri.indexOf('?q=') != -1) ? item : item.replace(/%26/g, '%2526').replace(/%23/g, '%2523').replace(/\/\//g, '/%252F');
 };
 
 // Global Killswitch on the <html> element
 if (Drupal.jsEnabled) {
-  document.documentElement.className = 'js';
+  $(document.documentElement).addClass('js');
 }
diff -Naur drupal-5.0/misc/farbtastic/farbtastic.css drupal-5.23/misc/farbtastic/farbtastic.css
--- drupal-5.0/misc/farbtastic/farbtastic.css	2006-10-31 16:03:37.000000000 +0100
+++ drupal-5.23/misc/farbtastic/farbtastic.css	2007-04-18 05:38:58.000000000 +0200
@@ -1,3 +1,5 @@
+/* $Id: farbtastic.css,v 1.2.2.1 2007/04/18 03:38:58 drumm Exp $ */
+
 .farbtastic {
   position: relative;
 }
@@ -30,4 +32,3 @@
   overflow: hidden;
   background: url(marker.png) no-repeat;
 }
-
diff -Naur drupal-5.0/misc/favicon.ico drupal-5.23/misc/favicon.ico
--- drupal-5.0/misc/favicon.ico	2006-10-29 14:17:37.000000000 +0100
+++ drupal-5.23/misc/favicon.ico	2007-09-21 13:23:46.000000000 +0200
@@ -1 +1,3 @@
-         h     (                                    ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ Ç´”j¤F¹”hç£~=é¶—f½Ì¸˜pÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÙÎºD•hàŠS ýˆN ýµ’XýÁ£pý´Sý½›bý°ˆEåÖÇ²Lÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ØË¶H’]ø“[ý¥{5ý©‚>ý“`ý[ýŸr&ýŸr&ý˜hý múØÊµPÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ±y Þ·n ýÛº„ýÿÿÿýÿÿÿýðèÜý¾Ÿlý³Sý±ŒOý¦|6ýôðçýæÝÐåÿÿÿ ÿÿÿ ÿÿÿ Ë³Žp¾u ý»r ýñáÉýÿÿÿýÿÿÿýÿÿÿýÿÿÿýâÖÂý¾ oýôîåýÿÿÿýÿÿÿýÑÂ¨uÿÿÿ ÿÿÿ ¸‹B½¾u ý·l ýß½ˆýÿÿÿýÿÿÿýÿÿÿýÿýûýáÄ“ý­7ýË´ŽýýüúýÿÿÿýÂ©Áÿÿÿ ÿÿÿ °ué½u ý¹q ý»týÛ·}ýñâÊýêÔ°ýÊ“:ý·k ý²j ý‘U ý§€?ýÊ±†ý›n&éÿÿÿ ÿÿÿ ±xã½u ýºs ý¹q ý¶k ý¸p ý·m ý·m ýºs ý¼t ý¹r ý’X ý†N ý”gàÿÿÿ ÿÿÿ »“R­½s ý¹q ýºs ýºs ýºr ýºs ýºs ýºs ýºs ý½t ý²n ýZ ý«ŠT«ÿÿÿ ÿÿÿ ÓÁ¤ZÃƒý¼vý·m ý¹r ýºs ýºs ýºs ýºs ýºs ýºs ý¼t ýš` ýÏ¿¦Wÿÿÿ ÿÿÿ ÿÿÿ Ðº•ÇöäÈýÎ›Gý¹p ý¹p ýºs ýºs ýºs ýºs ýºs ý¿v ý¬€:Åÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ éãØ(äÝÑãÿÿÿýäÅ“ý¼wý¸p ýºs ýºs ýºs ý¿v ý´xççßÒ+ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÖÈ³½ÿÿÿýíÕ¯ý¼vý¹q ý¾u ý½u ý´€,ÓæÝÐ.ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÚÏ¼Rá×ÇÝÔ¢Rýºo ýµ‚.ÐÐ¼œbÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ Ï®wí¼–Z¥ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÐÀ¦^ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ü?  ð  à  À  À  €  €  €  €  À  À  à  ð  ü?  þ  ÿÿ  
\ No newline at end of file
+         h  &          ¨  Ž  (                                                     }N ‹W zX ²‹W å™l!ï¢y6Î^˜„R "                            ‹W G‰V àŽY ÿŽY ÿ¶”[ÿÄ©{ÿ±PÿÁ¥uÿ¤|6ôˆU z                    ŠV CŽX üŽZÿ¡v-ÿ¦|7ÿŽY ÿ•cÿªƒAÿŸs(ÿ™jÿ“aÿ“ez            —^ +£e õ·q ÿÛ¹‚ÿÿÿÿÿÿÿÿÿìãÕÿ¾ nÿ®ˆJÿºšdÿ¡u,ÿíåØÿïèÝýu19        ¡d «ºs ÿºs ÿôêÚÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ÷óîÿÓ¾œÿûùöÿÿÿÿÿÿÿÿÿ»lµ        ªj âºs ÿºs ÿÜ¹ÿÿÿÿÿÿÿÿÿÿÿÿÿþþþÿâÊ¤ÿ¨{2ÿÌ´Œÿûù÷ÿÿÿÿÿÆ­„ß        ®l ýºs ÿºs ÿ¼x
+ÿÖ¬hÿíÛ¾ÿÜ¹€ÿÂ„ ÿºs ÿ¶q ÿ™_ ÿ™iÿÁ¤tÿ’bò        ­k üºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ¸r ÿ–] ÿŽY ÿ‹W â        ©h éºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ²n ÿY ÿ‹W ·         c ¼ºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ›` ÿ‡T ‡        ”\ Ø¶~ýâÃ‘ÿÁ‚ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿš_ íP             ½“N’ùôëÿøðäÿÒ£Wÿºsÿºs ÿºs ÿºs ÿºs ÿºs ÿ±n ÿ—^ p                    ·IcðãÏþüùóÿß»„ÿºs ÿºs ÿºs ÿºs ÿ®l ýš_ m                            •\ Ì«uåóèÖÿÄˆ'ÿºs ÿ´o ÿ£e Ï—] /                                        ¬z,Úµyÿ«i ÷˜^ =                                                    ªw#è–] 5                            ü  ð  à  À  €  €  €  €  €  €  À  À  ð  ø  ü  þÿ  (       @                              ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ‚Q GƒR ›ˆU ÃˆU ÝˆU ó†T ùƒR ë€P áO ÀO |Q ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ uI O ‡T ÚŒW ÿŽY ÿŽY ÿŽY ÿŽY ÿžq&ÿ»›fÿ¼œhÿ»œgÿ¤{7ÿˆVó„R  ‚Q ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ‚Q +€P ÞŠV ÿŽY ÿŽY ÿŽY ÿŽY ÿ¢v.ÿãÕÀÿëâÓÿ×Å¦ÿË³‹ÿÐº–ÿßÑ¹ÿëáÒÿÆ«ÿŠXóƒR uÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ƒR ^†S ïX ÿŽY ÿŽY ÿŽY ÿŽY ÿŽY ÿœm ÿ°‹NÿŽY ÿŽY ÿŽY ÿŽY ÿŽY ÿ\ÿ¶”\ÿ™jÿ‹W ÿƒR «Q ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ƒR ZŠV ùŽY ÿŽY ÿŽY ÿŽY ÿŽY ÿŽY ÿŽY ÿŽY ÿŽY ÿŽY ÿŽZÿŽY ÿŽY ÿŽY ÿŽY ÿŽYÿŽY ÿŽY ÿX ÿƒR ©ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ †T 5ŠV ïZ ÿ–] ÿ”\ ÿ–dÿ¾ nÿÎ·‘ÿÒ½›ÿºšdÿp$ÿŽY ÿŽY ÿ«„CÿØÆ¨ÿo#ÿ‘^ÿºšeÿ½žkÿŽY ÿŽY ÿ¥{5ÿ·–aÿˆY‹ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ‚Q ’Z à²n ÿ¹r ÿºs ÿÀÿ÷îâÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßÐ·ÿ¤y2ÿŽY ÿ«ƒBÿã×ÂÿïçÛÿÚÉ­ÿ“`ÿŽY ÿ¹™cÿûúøÿÿÿÿÿ×Æªû€P (ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ —] ´¸r ÿºs ÿºs ÿºs ÿåÊŸÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþÿØÅ§ÿškÿŽY ÿŽY ÿŽY ÿŽYÿÍ¶ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ«‰RÆÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ŽY §h úºs ÿºs ÿºs ÿºs ÿóèÖÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûùöÿÉ°‡ÿ t*ÿškÿÙÇªÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÖÄ§ýQ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ”[ €·q ÿºs ÿºs ÿºs ÿºs ÿòåÐÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿñêàÿ‚Q ‚ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ œa Öºs ÿºs ÿºs ÿºs ÿºs ÿß¿ŒÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèÜÉÿ¸—`ÿ®‰JÿÙÇªÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýüûÿ…S¾ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ¥f îºs ÿºs ÿºs ÿºs ÿºs ÿ¾|ÿ÷ïâÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüúöÿØ±qÿ¹sÿ d ÿŽY ÿŽY ÿ­‡GÿïèÜÿÿÿÿÿÿÿÿÿÿÿÿÿêáÑÿ‡T Ùÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ¨g úºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿÆ‹-ÿòåÑÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèÑ­ÿÂ„ ÿºs ÿºs ÿºs ÿªj ÿZ ÿŽY ÿ[ÿ¹™cÿñêàÿþþþÿ»›fÿ‡T ëÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ªh ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ»uÿÑ¢Vÿß¿ŒÿäÉÿÖ¬hÿÆ‹-ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ²n ÿ”\ ÿŽY ÿŽY ÿ\ÿ–fÿŽY ÿ‡T ûÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ¥f þºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿµp ÿ’[ ÿŽY ÿŽY ÿŽY ÿŽY ÿ…S ðÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ a úºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ±m ÿZ ÿŽY ÿŽY ÿŽY ÿƒR äÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ —] òºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ©i ÿŽY ÿŽY ÿŽY ÿQ Óÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ •\ Éºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ¹r ÿ”\ ÿŽY ÿŽY ÿQ ™ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ “[ `²n ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ£e ÿŽY ÿŠV ÿ‚Q 9ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ š_ ï¿|ÿÁÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ®l ÿŽY ÿ‚Q Éÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ “[ QÔ¬kÿåÈ™ÿÝ¸{ÿË•>ÿºtÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ¯l ÿ‰V ø€P :ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ¸‹AÞþþþÿùôêÿîÚ»ÿÜ¸}ÿÅˆ'ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ¬j ÿ…S œÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ”\ ÞÅ›ýþþþÿÿÿÿÿû÷ðÿéÐ§ÿÓ¤Xÿºtÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿžb ñ†T ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ “[ 6×ºŠüþþþÿÿÿÿÿþýûÿîÛ¼ÿÚ²rÿ¾{ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ¬k û”\ Uÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ “[ (Ì¬wúþþýÿÿÿÿÿÿÿÿÿôèÔÿß½‡ÿ¿~ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ¥f ø–] 9ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ”\ ¯ƒ;ÜóèØÿÿÿÿÿÿÿÿÿùóèÿÞº‚ÿ¼wÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿºs ÿ¶p ÿœa é‘Z ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ —a	mË«yúüúöÿÿÿÿÿòåÎÿÐŸPÿºs ÿºs ÿºs ÿºs ÿºs ÿ·q ÿ¡c ù”\ Ÿÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ¤s$¶çÕ·ÿôéÖÿÖªdÿºs ÿºs ÿºs ÿ¸q ÿ¢d ú”\ ¨”\ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ “[ %Æ¤lõ÷ðäÿ½zÿºs ÿ®l ÿ–] ¶–\ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ “\ ßÈ¤ýÑ¢Vÿ¯l ÿ–] šÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ »“Sâ¾‡.ÿ–] ¤ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ –`
+——_¯ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿÿÿ ÿðÿÿÀÿÿ  ÿþ  ?ü  ø  ð  à  à  À  À  À  À  À  À  À  À  À  à  à  ð  ð  ø  ü  ?þ  ÿ  ÿÿÀÿÿàÿÿøÿÿü?ÿÿüÿÿüÿÿ
\ No newline at end of file
diff -Naur drupal-5.0/misc/textarea.js drupal-5.23/misc/textarea.js
--- drupal-5.0/misc/textarea.js	2006-09-07 10:05:31.000000000 +0200
+++ drupal-5.23/misc/textarea.js	2007-04-18 04:41:19.000000000 +0200
@@ -1,10 +1,12 @@
-// $Id: textarea.js,v 1.11 2006/09/07 08:05:31 dries Exp $
+// $Id: textarea.js,v 1.11.2.1 2007/04/18 02:41:19 drumm Exp $
 
 Drupal.textareaAttach = function() {
   $('textarea.resizable:not(.processed)').each(function() {
     var textarea = $(this).addClass('processed'), staticOffset = null;
 
-    $(this).wrap('<div class="resizable-textarea"></div>')
+    // When wrapping the text area, work around an IE margin bug.  See:
+    // http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout
+    $(this).wrap('<div class="resizable-textarea"><span></span></div>')
       .parent().append($('<div class="grippie"></div>').mousedown(startDrag));
 
     var grippie = $('div.grippie', $(this).parent())[0];
diff -Naur drupal-5.0/modules/aggregator/aggregator.info drupal-5.23/modules/aggregator/aggregator.info
--- drupal-5.0/modules/aggregator/aggregator.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/aggregator/aggregator.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/aggregator/aggregator.module drupal-5.23/modules/aggregator/aggregator.module
--- drupal-5.0/modules/aggregator/aggregator.module	2006-12-26 11:28:12.000000000 +0100
+++ drupal-5.23/modules/aggregator/aggregator.module	2008-04-28 09:41:23.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: aggregator.module,v 1.324 2006/12/26 10:28:12 dries Exp $
+// $Id: aggregator.module,v 1.324.2.3 2008/04/28 07:41:23 drumm Exp $
 
 /**
  * @file
@@ -51,11 +51,14 @@
       'callback arguments' => array('aggregator_form_category'),
       'access' => $edit,
       'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/content/aggregator/remove',
+    $items[] = array(
+      'path' => 'admin/content/aggregator/remove',
       'title' => t('Remove items'),
-      'callback' => 'aggregator_admin_remove_feed',
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('aggregator_admin_remove_feed'),
       'access' => $edit,
-      'type' => MENU_CALLBACK);
+      'type' => MENU_CALLBACK,
+    );
     $items[] = array('path' => 'admin/content/aggregator/update',
       'title' => t('Update items'),
       'callback' => 'aggregator_admin_refresh_feed',
@@ -342,7 +345,7 @@
   if ($form_values['op'] == t('Submit')) {
     // Check for duplicate titles
     if (isset($form_values['cid'])) {
-      $category = db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s' AND cid != %d", $form_values['title'], $form_values['cid']));
+      $category = db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s' AND cid <> %d", $form_values['title'], $form_values['cid']));
     }
     else {
       $category = db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s'", $form_values['title']));
@@ -473,10 +476,10 @@
   if ($form_values['op'] == t('Submit')) {
     // Check for duplicate titles
     if (isset($form_values['fid'])) {
-      $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE (title = '%s' OR url='%s') AND fid != %d", $form_values['title'], $form_values['url'], $form_values['fid']);
+      $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE (title = '%s' OR url = '%s') AND fid <> %d", $form_values['title'], $form_values['url'], $form_values['fid']);
     }
     else {
-      $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = '%s' OR url='%s'", $form_values['title'], $form_values['url']);
+      $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = '%s' OR url = '%s'", $form_values['title'], $form_values['url']);
     }
     while ($feed = db_fetch_object($result)) {
       if (strcasecmp($feed->title, $form_values['title']) == 0) {
@@ -950,7 +953,7 @@
 
 function aggregator_save_item($edit) {
   if ($edit['iid'] && $edit['title']) {
-    db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['iid'], $edit['timestamp'], $edit['gid']);
+    db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']);
   }
   else if ($edit['iid']) {
     db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']);
@@ -1001,12 +1004,29 @@
   return $output;
 }
 
+function aggregator_admin_remove_feed($fid) {
+  $feed = aggregator_get_feed($fid);
+  return confirm_form(
+    array(
+      'feed' => array(
+        '#type' => 'value',
+        '#value' => $feed,
+      ),
+    ),
+    t('Are you sure you want to remove all items from the feed %feed?', array('%feed' => $feed['title'])),
+    'admin/content/aggregator',
+    t('This action cannot be undone.'),
+    t('Remove items'),
+    t('Cancel')
+  );
+}
+
 /**
- * Menu callback; removes all items from a feed, then redirects to the overview page.
+ * Remove all items from a feed and redirect to the overview page.
  */
-function aggregator_admin_remove_feed($feed) {
-  aggregator_remove(aggregator_get_feed($feed));
-  drupal_goto('admin/content/aggregator');
+function aggregator_admin_remove_feed_submit($form_id, $form_values) {
+  aggregator_remove($form_values['feed']);
+  return 'admin/content/aggregator';
 }
 
 /**
diff -Naur drupal-5.0/modules/block/block.info drupal-5.23/modules/block/block.info
--- drupal-5.0/modules/block/block.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/block/block.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - required
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/block/block.module drupal-5.23/modules/block/block.module
--- drupal-5.0/modules/block/block.module	2007-01-11 09:54:44.000000000 +0100
+++ drupal-5.23/modules/block/block.module	2009-01-14 06:43:04.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: block.module,v 1.246 2007/01/11 08:54:44 dries Exp $
+// $Id: block.module,v 1.246.2.11 2009/01/14 05:43:04 drumm Exp $
 
 /**
  * @file
@@ -131,7 +131,7 @@
       break;
 
     case 'view':
-      $block = db_fetch_object(db_query('SELECT * FROM {boxes} WHERE bid = %d', $delta));
+      $block = db_fetch_object(db_query('SELECT body, format FROM {boxes} WHERE bid = %d', $delta));
       $data['content'] = check_markup($block->body, $block->format, FALSE);
       return $data;
   }
@@ -282,7 +282,7 @@
   foreach ($form_values as $block) {
     $block['status'] = $block['region'] != BLOCK_REGION_NONE;
     $block['region'] = $block['status'] ? $block['region'] : '';
-    db_query("UPDATE {blocks} SET status = %d, weight = %d, region = '%s', throttle = %d WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block['status'], $block['weight'], $block['region'], $block['throttle'], $block['module'], $block['delta'], $block['theme']);
+    db_query("UPDATE {blocks} SET status = %d, weight = %d, region = '%s', throttle = %d WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block['status'], $block['weight'], $block['region'], isset($block['throttle']) ? $block['throttle'] : 0, $block['module'], $block['delta'], $block['theme']);
   }
   drupal_set_message(t('The block settings have been updated.'));
   cache_clear_all();
@@ -320,12 +320,12 @@
       // Output region header
       if ($status && $region != $last_region) {
         $region_title = t('@region', array('@region' => drupal_ucfirst($block_regions[$region])));
-        $rows[] = array(array('data' => $region_title, 'class' => 'region', 'colspan' => ($throttle ? 7 : 6)));
+        $rows[] = array(array('data' => $region_title, 'class' => 'region', 'colspan' => ($throttle ? 6 : 5)));
         $last_region = $region;
       }
       // Output disabled header
       elseif ($status != $last_status) {
-        $rows[] = array(array('data' => t('Disabled'), 'class' => 'region', 'colspan' => ($throttle ? 7 : 6)));
+        $rows[] = array(array('data' => t('Disabled'), 'class' => 'region', 'colspan' => ($throttle ? 6 : 5)));
         $last_status = $status;
       }
 
@@ -359,7 +359,7 @@
 }
 
 function block_box_get($bid) {
-  return db_fetch_array(db_query("SELECT bx.*, title FROM {boxes} bx INNER JOIN {blocks} bl ON bx.bid = bl.delta WHERE module = 'block' AND bid = %d", $bid));
+  return db_fetch_array(db_query("SELECT * FROM {boxes} WHERE bid = %d", $bid));
 }
 
 /**
@@ -524,7 +524,7 @@
  */
 function block_box_delete($bid = 0) {
   $box = block_box_get($bid);
-  $form['info'] = array('#type' => 'hidden', '#value' => $box['info'] ? $box['info'] : $box['title']);
+  $form['info'] = array('#type' => 'hidden', '#value' => $box['info']);
   $form['bid'] = array('#type' => 'hidden', '#value' => $bid);
 
   return confirm_form($form, t('Are you sure you want to delete the block %name?', array('%name' => $box['info'])), 'admin/build/block', '', t('Delete'), t('Cancel'));
@@ -535,7 +535,7 @@
  */
 function block_box_delete_submit($form_id, $form_values) {
   db_query('DELETE FROM {boxes} WHERE bid = %d', $form_values['bid']);
-  db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = %d", $form_values['bid']);
+  db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = '%s'", $form_values['bid']);
   drupal_set_message(t('The block %name has been removed.', array('%name' => $form_values['info'])));
   cache_clear_all();
   return 'admin/build/block';
@@ -589,18 +589,19 @@
  * Allow users to decide which custom blocks to display when they visit
  * the site.
  */
-function block_user($type, $edit, &$user, $category = NULL) {
-  global $user;
+function block_user($type, $edit, &$account, $category = NULL) {
   switch ($type) {
     case 'form':
       if ($category == 'account') {
-        $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN (%s) OR r.rid IS NULL) ORDER BY b.weight, b.module", implode(',', array_keys($user->roles)));
+        $rids = array_keys($account->roles);
+        $placeholders = implode(',', array_fill(0, count($rids), '%d'));
+        $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN ($placeholders) OR r.rid IS NULL) ORDER BY b.weight, b.module", $rids);
         $form['block'] = array('#type' => 'fieldset', '#title' => t('Block configuration'), '#weight' => 3, '#collapsible' => TRUE, '#tree' => TRUE);
         while ($block = db_fetch_object($result)) {
           $data = module_invoke($block->module, 'block', 'list');
           if ($data[$block->delta]['info']) {
             $return = TRUE;
-            $form['block'][$block->module][$block->delta] = array('#type' => 'checkbox', '#title' => check_plain($data[$block->delta]['info']), '#default_value' => isset($user->block[$block->module][$block->delta]) ? $user->block[$block->module][$block->delta] : ($block->custom == 1));
+            $form['block'][$block->module][$block->delta] = array('#type' => 'checkbox', '#title' => check_plain($data[$block->delta]['info']), '#default_value' => isset($account->block[$block->module][$block->delta]) ? $account->block[$block->module][$block->delta] : ($block->custom == 1));
           }
         }
 
@@ -641,7 +642,9 @@
   static $blocks = array();
 
   if (!count($blocks)) {
-    $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (%s) OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", $theme_key, implode(',', array_keys($user->roles)));
+    $rids = array_keys($user->roles);
+    $placeholders = implode(',', array_fill(0, count($rids), '%d'));
+    $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN ($placeholders) OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", array_merge(array($theme_key), $rids));
     while ($block = db_fetch_object($result)) {
       if (!isset($blocks[$block->region])) {
         $blocks[$block->region] = array();
@@ -681,8 +684,23 @@
       else {
         $page_match = TRUE;
       }
+      $block->enabled = $enabled;
+      $block->page_match = $page_match;
+      $blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
+    }
+  }
 
-      if ($enabled && $page_match) {
+  // Create an empty array if there were no entries
+  if (!isset($blocks[$region])) {
+    $blocks[$region] = array();
+  }
+
+  foreach ($blocks[$region] as $key => $block) {
+    // Render the block content if it has not been created already.
+    if (!isset($block->content)) {
+      // Erase the block from the static array - we'll put it back if it has content.
+      unset($blocks[$region][$key]);
+      if ($block->enabled && $block->page_match) {
         // Check the current throttle status and see if block should be displayed
         // based on server load.
         if (!($block->throttle && (module_invoke('throttle', 'status') > 0))) {
@@ -704,9 +722,5 @@
       }
     }
   }
-  // Create an empty array if there were no entries
-  if (!isset($blocks[$region])) {
-    $blocks[$region] = array();
-  }
   return $blocks[$region];
 }
diff -Naur drupal-5.0/modules/blog/blog.info drupal-5.23/modules/blog/blog.info
--- drupal-5.0/modules/blog/blog.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/blog/blog.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/blog/blog.module drupal-5.23/modules/blog/blog.module
--- drupal-5.0/modules/blog/blog.module	2006-12-10 21:34:02.000000000 +0100
+++ drupal-5.23/modules/blog/blog.module	2008-07-06 02:27:42.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: blog.module,v 1.271 2006/12/10 20:34:02 dries Exp $
+// $Id: blog.module,v 1.271.2.3 2008/07/06 00:27:42 drumm Exp $
 
 /**
  * @file
@@ -48,7 +48,7 @@
  */
 function blog_user($type, &$edit, &$user) {
   if ($type == 'view' && user_access('edit own blog', $user)) {
-    $items[] = array('title' => t('Blog'),
+    $items['blog'] = array('title' => t('Blog'),
       'value' => l(t('View recent blog entries'), "blog/$user->uid", array('title' => t("Read @username's latest blog entries.", array('@username' => $user->name)))),
       'class' => 'blog',
     );
@@ -117,9 +117,10 @@
   else if ($a == 'feed') {
     return blog_feed_last();
   }
-  else {
+  else if ($a === NULL) {
     return blog_page_last();
   }
+  drupal_not_found();
 }
 
 /**
@@ -147,7 +148,7 @@
       $output = '';
     }
 
-    $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE 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);
+    $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);
     while ($node = db_fetch_object($result)) {
       $output .= node_view(node_load($node->nid), 1);
     }
diff -Naur drupal-5.0/modules/blogapi/blogapi.info drupal-5.23/modules/blogapi/blogapi.info
--- drupal-5.0/modules/blogapi/blogapi.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/blogapi/blogapi.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/blogapi/blogapi.install drupal-5.23/modules/blogapi/blogapi.install
--- drupal-5.0/modules/blogapi/blogapi.install	1970-01-01 01:00:00.000000000 +0100
+++ drupal-5.23/modules/blogapi/blogapi.install	2008-08-27 15:25:13.000000000 +0200
@@ -0,0 +1,90 @@
+<?php
+// $Id: blogapi.install,v 1.2.2.3 2008/08/27 13:25:13 drumm Exp $
+
+/**
+ * Implementation of hook_install().
+ */
+function blogapi_install() {
+  // Create table.
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      db_query("CREATE TABLE {blogapi_files} (
+        fid int NOT NULL auto_increment,
+        uid int unsigned NOT NULL default 0,
+        filepath varchar(255) NOT NULL default '',
+        filesize int unsigned NOT NULL default 0,
+        PRIMARY KEY (fid),
+        KEY uid (uid)
+      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
+      break;
+
+    case 'pgsql':
+      db_query("CREATE TABLE {blogapi_files} (
+        fid serial,
+        uid int_unsigned NOT NULL default 0,
+        filepath varchar(255) NOT NULL default '',
+        filesize int_unsigned NOT NULL default 0,
+        PRIMARY KEY (fid)
+      )");
+
+      db_query("CREATE INDEX {blogapi_files}_uid_idx ON {blogapi_files} (uid)");
+      break;
+  }
+
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function blogapi_uninstall() {
+  // Remove table.
+  db_query("DROP TABLE {blogapi_files}");
+}
+
+/**
+ * @defgroup updates-5.x-extra Extra blogapi updates for 5.x
+ * @{
+ */
+
+/**
+ * Add blogapi_files table to enable size restriction for BlogAPI file uploads.
+ *
+ * Added in Drupal 5.10 (and 6.4).
+ */
+function blogapi_update_5000() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("CREATE TABLE {blogapi_files} (
+        fid int NOT NULL auto_increment,
+        uid int unsigned NOT NULL default 0,
+        filepath varchar(255) NOT NULL default '',
+        filesize int unsigned NOT NULL default 0,
+        PRIMARY KEY (fid),
+        KEY uid (uid)
+      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
+      break;
+
+    case 'pgsql':
+      $ret[] = update_sql("CREATE TABLE {blogapi_files} (
+        fid serial,
+        uid int_unsigned NOT NULL default 0,
+        filepath varchar(255) NOT NULL default '',
+        filesize int_unsigned NOT NULL default 0,
+        PRIMARY KEY (fid)
+      )");
+
+      $ret[] = update_sql("CREATE INDEX {blogapi_files}_uid_idx ON {blogapi_files} (uid)");
+      break;
+  }
+
+  return $ret;
+}
+
+
+/**
+ * @} End of "defgroup updates-5.x-extra"
+ */
+
diff -Naur drupal-5.0/modules/blogapi/blogapi.module drupal-5.23/modules/blogapi/blogapi.module
--- drupal-5.0/modules/blogapi/blogapi.module	2007-01-05 20:05:54.000000000 +0100
+++ drupal-5.23/modules/blogapi/blogapi.module	2008-10-08 22:10:25.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: blogapi.module,v 1.100 2007/01/05 19:05:54 dries Exp $
+// $Id: blogapi.module,v 1.100.2.6 2008/10/08 20:10:25 drumm Exp $
 
 /**
  * @file
@@ -21,6 +21,13 @@
 }
 
 /**
+ * Implementation of hook_perm().
+ */
+function blogapi_perm() {
+  return array('administer content with blog api');
+}
+
+/**
  * Implementation of hook_xmlrpc().
  */
 function blogapi_xmlrpc() {
@@ -122,7 +129,7 @@
       t('Retrieve information about the text formatting plugins supported by the server.')),
     array(
       'mt.publishPost',
-      'blogap_mti_publish_post',
+      'blogapi_mt_publish_post',
       array('boolean', 'string', 'string', 'string'),
       t('Publish (rebuild) all of the static files related to an entry from your weblog. Equivalent to saving an entry in the system (but without the ping).')));
 }
@@ -138,7 +145,7 @@
     $types = _blogapi_get_node_types();
     $structs = array();
     foreach ($types as $type) {
-      $structs[] = array('url' => url('blog/' . $user->uid, NULL, NULL, TRUE), 'blogid' => $type, 'blogName' => $user->name . ": " . $type);
+      $structs[] = array('url' => url('blog/'. $user->uid, NULL, NULL, TRUE), 'blogid' => $type, 'blogName' => $user->name .": ". $type);
     }
     return $structs;
   }
@@ -161,7 +168,7 @@
       'firstname' => $name[0],
       'nickname' => $user->name,
       'email' => $user->mail,
-      'url' => url('blog/' . $user->uid, NULL, NULL, TRUE));
+      'url' => url('blog/'. $user->uid, NULL, NULL, TRUE));
   }
   else {
     return blogapi_error($user);
@@ -210,6 +217,11 @@
 
   node_invoke_nodeapi($edit, 'blogapi new');
 
+  $valid = blogapi_status_error_check($edit, $publish);
+  if ($valid !== TRUE) {
+    return $valid;
+  }
+
   node_validate($edit);
   if ($errors = form_get_errors()) {
     return blogapi_error(implode("\n", $errors));
@@ -247,7 +259,8 @@
   if (!node_access('update', $node)) {
     return blogapi_error(t('You do not have permission to update this post.'));
   }
-
+  // Save the original status for validation of permissions.
+  $original_status = $node->status;
   $node->status = $publish;
 
   // check for bloggerAPI vs. metaWeblogAPI
@@ -263,6 +276,11 @@
 
   node_invoke_nodeapi($node, 'blogapi edit');
 
+  $valid = blogapi_status_error_check($node, $original_status);
+  if ($valid !== TRUE) {
+    return $valid;
+  }
+
   node_validate($node);
   if ($errors = form_get_errors()) {
     return blogapi_error(implode("\n", $errors));
@@ -296,6 +314,33 @@
 }
 
 /**
+ * Check that the user has permission to save the node with the chosen status.
+ *
+ * @return
+ *   TRUE if no error, or the blogapi_error().
+ */
+function blogapi_status_error_check($node, $original_status) {
+  
+  $node = (object) $node;
+
+  $node_type_default = variable_get('node_options_'. $node->type, array('status', 'promote'));
+
+  // If we don't have the 'administer nodes' permission and the status is
+  // changing or for a new node the status is not the content type's default,
+  // then return an error.
+  if (!user_access('administer nodes') && (($node->status != $original_status) || (empty($node->nid) && $node->status != in_array('status', $node_type_default)))) {
+    if ($node->status) {
+      return blogapi_error(t('You do not have permission to publish this type of post. Please save it as a draft instead.'));
+    }
+    else {
+      return blogapi_error(t('You do not have permission to save this post as a draft. Please publish it instead.'));
+    }
+  }
+  return TRUE;
+}
+
+
+/**
  * Blogging API callback. Removes the specified blog node.
  */
 function blogapi_blogger_delete_post($appkey, $postid, $username, $password, $publish) {
@@ -327,7 +372,7 @@
   else {
     $result = db_query_range("SELECT n.nid, n.title, n.created, u.name FROM {node} n, {users} u WHERE n.uid = u.uid AND n.type = '%s' AND n.uid = %d ORDER BY n.created DESC", $type, $user->uid, 0, $number_of_posts);
   }
-  $blogs = array ();
+  $blogs = array();
   while ($blog = db_fetch_object($result)) {
     $blogs[] = _blogapi_get_post($blog, $bodies);
   }
@@ -355,20 +400,63 @@
     return blogapi_error($user);
   }
 
+  $usersize = 0;
+  $uploadsize = 0;
+
+  $roles = array_intersect(user_roles(0, 'administer content with blog api'), $user->roles);
+
+  foreach ($roles as $rid => $name) {
+    $extensions .= ' '. strtolower(variable_get("blogapi_extensions_$rid", variable_get('blogapi_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp')));
+    $usersize= max($usersize, variable_get("blogapi_usersize_$rid", variable_get('blogapi_usersize_default', 1)) * 1024 * 1024);
+    $uploadsize = max($uploadsize, variable_get("blogapi_uploadsize_$rid", variable_get('blogapi_uploadsize_default', 1)) * 1024 * 1024);
+  }
+
+  $filesize = strlen($file['bits']);
+
+  if ($filesize > $uploadsize) {
+    return blogapi_error(t('It is not possible to upload the file, because it exceeded the maximum filesize of @maxsize.', array('@maxsize' => format_size($uploadsize))));
+  }
+
+  if (_blogapi_space_used($user->uid) + $filesize > $usersize) {
+    return blogapi_error(t('The file can not be attached to this post, because the disk quota of @quota has been reached.', array('@quota' => format_size($usersize))));
+  }
+
+  // Only allow files with whitelisted extensions and convert remaining dots to
+  // underscores to prevent attacks via non-terminal executable extensions with
+  // files such as exploit.php.jpg.
+
+  $whitelist = array_unique(explode(' ', trim($extensions)));
+
   $name = basename($file['name']);
+
+  if ($extension_position = strrpos($name, '.')) {
+    $filename = drupal_substr($name, 0, $extension_position);
+    $final_extension = drupal_substr($name, $extension_position + 1);
+
+    if (!in_array(strtolower($final_extension), $whitelist)) {
+      return blogapi_error(t('It is not possible to upload the file, because it is only possible to upload files with the following extensions: @extensions', array('@extensions' => implode(' ', $whitelist))));
+    }
+
+    $filename = str_replace('.', '_', $filename);
+    $filename .= '.'. $final_extension;
+  }
+
   $data = $file['bits'];
 
   if (!$data) {
     return blogapi_error(t('No file sent.'));
   }
 
-  if (!$file = file_save_data($data, $name)) {
+  if (!$file = file_save_data($data, $filename)) {
     return blogapi_error(t('Error storing file.'));
   }
 
+  db_query("INSERT INTO {blogapi_files} (uid, filepath, filesize) VALUES (%d, '%s', %d)", $user->uid, $file, $filesize);
+
   // Return the successful result.
   return array('url' => file_create_url($file), 'struct');
 }
+
 /**
  * Blogging API callback. Returns a list of the taxonomy terms that can be
  * associated with a blog node.
@@ -383,7 +471,7 @@
       foreach ($terms as $term) {
         $term_name = $term->name;
         foreach (module_invoke('taxonomy', 'get_parents', $term->tid, 'tid') as $parent) {
-          $term_name = $parent->name . '/' . $term_name;
+          $term_name = $parent->name .'/'. $term_name;
         }
         $categories[] = array('categoryName' => $term_name, 'categoryId' => $term->tid);
       }
@@ -421,7 +509,7 @@
   foreach ($terms as $term) {
     $term_name = $term->name;
     foreach (module_invoke('taxonomy', 'get_parents', $term->tid, 'tid') as $parent) {
-      $term_name = $parent->name . '/' . $term_name;
+      $term_name = $parent->name .'/'. $term_name;
     }
     $categories[] = array('categoryName' => $term_name, 'categoryId' => $term->tid, 'isPrimary' => TRUE);
   }
@@ -442,11 +530,60 @@
   foreach ($categories as $category) {
     $node->taxonomy[] = $category['categoryId'];
   }
+  $validated = blogapi_mt_validate_terms($node);
+  if ($validated !== TRUE) {
+    return $validated;
+  }
   node_save($node);
   return TRUE;
 }
 
 /**
+ * Blogging API helper - find allowed taxonomy terms for a node type.
+ */
+function blogapi_mt_validate_terms($node) {
+  // We do a lot of heavy lifting here since taxonomy module doesn't have a
+  // stand-alone validation function.
+  if (module_exists('taxonomy')) {
+    $found_terms = array();
+    if (!empty($node->taxonomy)) {
+      $term_list = array_unique($node->taxonomy);
+      $placeholders = implode(', ', array_fill(0, count($term_list), '%d'));
+      $params = $term_list;
+      $params[] = $node->type;
+      $result = db_query(db_rewrite_sql("SELECT t.tid, t.vid FROM {term_data} t INNER JOIN {vocabulary_node_types} n ON t.vid = n.vid WHERE t.tid IN (". $placeholders .") AND n.type = '%s'", 't', 'tid'), $params);
+      $found_terms = array();
+      $found_count = 0;
+      while ($term = db_fetch_object($result)) {
+        $found_terms[$term->vid][$term->tid] = $term->tid;
+        $found_count++;
+      }
+      // If the counts don't match, some terms are invalid or not accessible to this user.
+      if (count($term_list) != $found_count) {
+        return blogapi_error(t('Invalid categories submitted.'));
+      }
+    }
+    // Look up all the vocabularies for this node type.
+    $result2 = db_query(db_rewrite_sql("SELECT v.vid, v.name, v.required, v.multiple FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s'", 'v', 'vid'), $node->type);
+    // Check each vocabulary associated with this node type.
+    while ($vocabulary = db_fetch_object($result2)) {
+      // Required vocabularies must have at least one term.
+      if ($vocabulary->required && empty($found_terms[$vocabulary->vid])) {
+        return blogapi_error(t('A category from the @vocabulary_name vocabulary is required.', array('@vocabulary_name' => $vocabulary->name)));
+      }
+      // Vocabularies that don't allow multiple terms may have at most one.
+      if (!($vocabulary->multiple) && (isset($found_terms[$vocabulary->vid]) && count($found_terms[$vocabulary->vid]) > 1)) {
+        return blogapi_error(t('You may only choose one category from the @vocabulary_name vocabulary.'), array('@vocabulary_name' => $vocabulary->name));
+      }
+    }
+  }
+  elseif (!empty($node->taxonomy)) {
+    return blogapi_error(t('Error saving categories. This feature is not available.'));
+  }
+  return TRUE;
+}
+
+/**
  * Blogging API callback. Sends a list of available input formats.
  */
 function blogapi_mt_supported_text_filters() {
@@ -467,7 +604,7 @@
 /**
  * Blogging API callback. Publishes the given node
  */
-function blogap_mti_publish_post($postid, $username, $password) {
+function blogapi_mt_publish_post($postid, $username, $password) {
   $user = blogapi_validate_user($username, $password);
   if (!$user->uid) {
     return blogapi_error($user);
@@ -477,11 +614,16 @@
     return blogapi_error(t('Invalid post.'));
   }
 
-  $node->status = 1;
-  if (!node_access('update', $node)) {
+  // Nothing needs to be done if already published.
+  if ($node->status) {
+    return;
+  }
+
+  if (!node_access('update', $node) || !user_access('administer nodes')) {
     return blogapi_error(t('You do not have permission to update this post.'));
   }
 
+  $node->status = 1;
   node_save($node);
 
   return TRUE;
@@ -510,7 +652,7 @@
   $user = user_authenticate($username, $password);
 
   if ($user->uid) {
-    if (user_access('edit own blog', $user)) {
+    if (user_access('administer content with blog api', $user)) {
       return $user;
     }
     else {
@@ -537,7 +679,7 @@
 }
 
 function blogapi_admin_settings() {
-  $node_types = node_get_types('names');
+  $node_types = array_map('check_plain', node_get_types('names'));
   $defaults = isset($node_types['blog']) ? array('blog' => 1) : array();
   $form['blogapi_node_types'] = array(
     '#type' => 'checkboxes',
@@ -548,6 +690,82 @@
     '#description' => t('Select the content types for which you wish to enable posting via blogapi. Each type will appear as a different "blog" in the client application (if supported).')
   );
 
+
+  $blogapi_extensions_default = variable_get('blogapi_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
+  $blogapi_uploadsize_default = variable_get('blogapi_uploadsize_default', 1);
+  $blogapi_usersize_default = variable_get('blogapi_usersize_default', 1);
+
+  $form['settings_general'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('File settings'),
+    '#collapsible' => TRUE,
+  );
+
+  $form['settings_general']['blogapi_extensions_default'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default permitted file extensions'),
+    '#default_value' => $blogapi_extensions_default,
+    '#maxlength' => 255,
+    '#description' => t('Default extensions that users can upload. Separate extensions with a space and do not include the leading dot.'),
+  );
+
+  $form['settings_general']['blogapi_uploadsize_default'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default maximum file size per upload'),
+    '#default_value' => $blogapi_uploadsize_default,
+    '#size' => 5,
+    '#maxlength' => 5,
+    '#description' => t('The default maximum file size a user can upload.'),
+    '#field_suffix' => t('MB')
+  );
+
+  $form['settings_general']['blogapi_usersize_default'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default total file size per user'),
+    '#default_value' => $blogapi_usersize_default,
+    '#size' => 5,
+    '#maxlength' => 5,
+    '#description' => t('The default maximum size of all files a user can have on the site.'),
+    '#field_suffix' => t('MB')
+  );
+
+  $form['settings_general']['upload_max_size'] = array('#value' => '<p>'. t('Your PHP settings limit the maximum file size per upload to %size.', array('%size' => format_size(file_upload_max_size()))).'</p>');
+
+  $roles = user_roles(0, 'administer content with blog api');
+  $form['roles'] = array('#type' => 'value', '#value' => $roles);
+
+  foreach ($roles as $rid => $role) {
+    $form['settings_role_'. $rid] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Settings for @role', array('@role' => $role)),
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+    );
+    $form['settings_role_'. $rid]['blogapi_extensions_'. $rid] = array(
+      '#type' => 'textfield',
+      '#title' => t('Permitted file extensions'),
+      '#default_value' => variable_get('blogapi_extensions_'. $rid, $blogapi_extensions_default),
+      '#maxlength' => 255,
+      '#description' => t('Extensions that users in this role can upload. Separate extensions with a space and do not include the leading dot.'),
+    );
+    $form['settings_role_'. $rid]['blogapi_uploadsize_'. $rid] = array(
+      '#type' => 'textfield',
+      '#title' => t('Maximum file size per upload'),
+      '#default_value' => variable_get('blogapi_uploadsize_'. $rid, $blogapi_uploadsize_default),
+      '#size' => 5,
+      '#maxlength' => 5,
+      '#description' => t('The maximum size of a file a user can upload (in megabytes).'),
+    );
+    $form['settings_role_'. $rid]['blogapi_usersize_'. $rid] = array(
+      '#type' => 'textfield',
+      '#title' => t('Total file size per user'),
+      '#default_value' => variable_get('blogapi_usersize_'. $rid, $blogapi_usersize_default),
+      '#size' => 5,
+      '#maxlength' => 5,
+      '#description' => t('The maximum size of all files a user can have on the site (in megabytes).'),
+    );
+  }
+
   return system_settings_form($form);
 }
 
@@ -648,7 +866,7 @@
     $node->body = $struct['mt_excerpt'] .'<!--break-->'.$node->body;
   }
   if ($struct['mt_text_more']) {
-    $node->body = $node->body . '<!--extended-->' . $struct['mt_text_more'];
+    $node->body = $node->body .'<!--extended-->'. $struct['mt_text_more'];
   }
 
   // mt_convert_breaks
@@ -667,7 +885,7 @@
 }
 
 function _blogapi_get_post($node, $bodies = TRUE) {
-  $xmlrpcval = array (
+  $xmlrpcval = array(
     'userid' => $node->name,
     'dateCreated' => xmlrpc_date($node->created),
     'title' => $node->title,
@@ -713,3 +931,7 @@
   return $types;
 }
 
+
+function _blogapi_space_used($uid) {
+  return db_result(db_query('SELECT SUM(filesize) FROM {blogapi_files} f WHERE f.uid = %d', $uid));
+}
\ No newline at end of file
diff -Naur drupal-5.0/modules/book/book.css drupal-5.23/modules/book/book.css
--- drupal-5.0/modules/book/book.css	2006-11-14 07:30:10.000000000 +0100
+++ drupal-5.23/modules/book/book.css	2007-01-29 19:54:29.000000000 +0100
@@ -1,4 +1,4 @@
-/* $Id: book.css,v 1.2 2006/11/14 06:30:10 drumm Exp $ */
+/* $Id: book.css,v 1.2.2.1 2007/01/29 18:54:29 dries Exp $ */
 
 .book-navigation .menu {
   border-top: 1px solid #888;
@@ -11,7 +11,7 @@
   padding: 0.5em;
 }
 .book-navigation .page-previous {
-  text-align: right;
+  text-align: left;
   width: 42%;
   display: block;
   float: left;
@@ -23,8 +23,8 @@
   float: left;
 }
 .book-navigation .page-next {
-  text-align: left;
+  text-align: right;
   width: 42%;
   display: block;
-  float: left;
+  float: right;
 }
diff -Naur drupal-5.0/modules/book/book.info drupal-5.23/modules/book/book.info
--- drupal-5.0/modules/book/book.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/book/book.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/book/book.module drupal-5.23/modules/book/book.module
--- drupal-5.0/modules/book/book.module	2007-01-09 09:31:22.000000000 +0100
+++ drupal-5.23/modules/book/book.module	2009-05-13 21:41:56.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: book.module,v 1.406 2007/01/09 08:31:22 drumm Exp $
+// $Id: book.module,v 1.406.2.2 2009/05/13 19:41:56 drumm Exp $
 
 /**
  * @file
@@ -277,7 +277,7 @@
   );
 
   $form['nid'] = array('#type' => 'value', '#value' => $nid);
-  if ($node->parent) {
+  if (isset($node->parent)) {
     $form['update'] = array('#type' => 'submit',
       '#value' => t('Update book outline'),
     );
@@ -702,8 +702,9 @@
   global $base_url;
   $html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
   $html .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
-  $html .= "<head>\n<title>". $title ."</title>\n";
+  $html .= "\n<head>\n";
   $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+  $html .= "\n<title>". $title ."</title>\n";
   $html .= '<base href="'. $base_url .'/" />' . "\n";
   $html .= "<style type=\"text/css\">\n@import url(misc/print.css);\n</style>\n";
   $html .= "</head>\n<body>\n". $content ."\n</body>\n</html>\n";
diff -Naur drupal-5.0/modules/color/color.css drupal-5.23/modules/color/color.css
--- drupal-5.0/modules/color/color.css	2006-11-23 12:05:46.000000000 +0100
+++ drupal-5.23/modules/color/color.css	2007-04-18 05:38:58.000000000 +0200
@@ -1,3 +1,5 @@
+/* $Id: color.css,v 1.2.2.1 2007/04/18 03:38:58 drumm Exp $ */
+
 /* Farbtastic placement */
 .color-form {
   max-width: 50em;
diff -Naur drupal-5.0/modules/color/color.info drupal-5.23/modules/color/color.info
--- drupal-5.0/modules/color/color.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/color/color.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/color/color.js drupal-5.23/modules/color/color.js
--- drupal-5.0/modules/color/color.js	2006-10-29 14:17:38.000000000 +0100
+++ drupal-5.23/modules/color/color.js	2007-04-18 05:38:58.000000000 +0200
@@ -1,3 +1,5 @@
+// $Id: color.js,v 1.1.2.1 2007/04/18 03:38:58 drumm Exp $
+
 if (Drupal.jsEnabled) {
   $(document).ready(function () {
     var form = $('#color_scheme_form .color-form');
diff -Naur drupal-5.0/modules/color/color.module drupal-5.23/modules/color/color.module
--- drupal-5.0/modules/color/color.module	2006-12-18 12:59:07.000000000 +0100
+++ drupal-5.23/modules/color/color.module	2008-12-21 03:56:30.000000000 +0100
@@ -1,22 +1,40 @@
 <?php
-// $Id: color.module,v 1.13 2006/12/18 11:59:07 unconed Exp $
+// $Id: color.module,v 1.13.2.6 2008/12/21 02:56:30 drumm Exp $
+
+/**
+ * Implementation of hook_help
+ */
+function color_help($section) {
+  switch ($section) {
+    case 'admin/help#color':
+      $output = '<p>'. t('Color module allows a site administrator to quickly and easily change the color scheme of the entire site. In order for color module to work however, a theme must be specifically designed to use the color changing features. The default theme, Garland, (as well as its fixed width counterpart, Minnelli) was designed to take advantage of these features. With color module, you can easily change the color of links, backgrounds, text, and more depending on which color module enabled theme you are using. Color module requires your <a href="@url">file download method</a> to be set to public.', array('@url' => url('admin/settings/file-system'))) .'</p>';
+      $output .= '<p>'. t("It is important to remember that color module saves a modified copy of the theme's style.css file in the files directory, and includes it after the theme's original style.css. This means that if you make any manual changes to your theme's style.css file, you must save your color settings again, even if they haven't changed. This causes the color module generated version of style.css in the files directory to be recreated using the new version of the original file.") .'</p>';
+      return $output;
+  }
+}
 
 /**
  * Implementation of hook_form_alter().
  */
 function color_form_alter($form_id, &$form) {
   // Insert the color changer into the theme settings page.
-  // TODO: Last condition in the following if disables color changer when private files are used this should be solved in a different way. See issue #92059.
-  if ($form_id == 'system_theme_settings' && color_get_info(arg(4)) && function_exists('gd_info') && variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) {
-    $form['color'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Color scheme'),
-      '#weight' => -1,
-      '#attributes' => array('id' => 'color_scheme_form'),
-      '#theme' => 'color_scheme_form',
-    );
-    $form['color'] += color_scheme_form(arg(4));
-    $form['#submit']['color_scheme_form_submit'] = array();
+  if ($form_id == 'system_theme_settings' && color_get_info(arg(4)) && function_exists('gd_info')) {
+    if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) != FILE_DOWNLOADS_PUBLIC) {
+      // Disables the color changer when the private download method is used.
+      // TODO: This should be solved in a different way. See issue #181003.
+      drupal_set_message(t('The color picker only works if the <a href="@url">download method</a> is set to public.', array('@url' => url('admin/settings/file-system'))));
+    }
+    else {
+      $form['color'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Color scheme'),
+        '#weight' => -1,
+        '#attributes' => array('id' => 'color_scheme_form'),
+        '#theme' => 'color_scheme_form',
+      );
+      $form['color'] += color_scheme_form(arg(4));
+      $form['#submit']['color_scheme_form_submit'] = array();
+    }
   }
 
   // Use the generated screenshot in the theme list
@@ -149,7 +167,7 @@
   // Wrapper
   $output .= '<div class="color-form clear-block">';
 
-  // Color Schemes
+  // Color schemes
   $output .= drupal_render($form['scheme']);
 
   // Palette
@@ -162,8 +180,9 @@
   // Preview
   $output .= drupal_render($form);
   $output .= '<h2>'. t('Preview') .'</h2>';
-  $output .= '<div id="preview"><div id="text"><h2>Lorem ipsum dolor</h2><p>Sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud <a href="#">exercitation ullamco</a> laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p></div><div id="img" style="background-image: url('. base_path() . $path . $info['preview_image'] .')" alt="" /></div></div>';
+  $output .= '<div id="preview"><div id="text"><h2>Lorem ipsum dolor</h2><p>Sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud <a href="#">exercitation ullamco</a> laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p></div><div id="img" style="background-image: url('. base_path() . $path . $info['preview_image'] .')" alt=""></div></div>';
 
+  // Close wrapper
   $output .= '</div>';
 
   return $output;
@@ -227,12 +246,10 @@
 
   // Prepare target locations for generated files
   $id = $theme .'-'. substr(md5(serialize($palette) . microtime()), 0, 8);
-  $paths['color'] = variable_get('file_directory_path', 'files') .'/color';
+  $paths['color'] = file_directory_path() .'/color';
   $paths['target'] = $paths['color'] .'/'. $id;
   foreach ($paths as $path) {
-    if (!is_dir($path)) {
-      mkdir($path);
-    }
+    file_check_directory($path, FILE_CREATE_DIRECTORY);
   }
   $paths['target'] = $paths['target'] .'/';
   $paths['id'] = $id;
@@ -248,13 +265,16 @@
   // Copy over neutral images
   foreach ($info['copy'] as $file) {
     $base = basename($file);
-    copy($paths['source'] . $file, $paths['target'] . $base);
+    $source = $paths['source'] . $file;
+    file_copy($source, $paths['target'] . $base);
     $paths['map'][$file] = $base;
     $paths['files'][] = $paths['target'] . $base;
   }
 
-  // Render new images
-  _color_render_images($theme, $info, $paths, $palette);
+  // Render new images, if base image exists
+  if ($info['base_image']) {
+    _color_render_images($theme, $info, $paths, $palette);
+  }
 
   // Rewrite stylesheet
   _color_rewrite_stylesheet($theme, $info, $paths, $palette);
@@ -338,6 +358,9 @@
   fwrite($file, $output);
   fclose($file);
   $paths['files'][] = $paths['stylesheet'];
+
+  // Set standard file permissions for webserver-generated files
+  @chmod($paths['stylesheet'], 0664);
 }
 
 /**
@@ -370,7 +393,7 @@
   // Render gradient.
   for ($y = 0; $y < $info['gradient'][3]; ++$y) {
     $color = _color_blend($target, $palette['top'], $palette['bottom'], $y / ($info['gradient'][3] - 1));
-    imagefilledrectangle($target, $info['gradient'][0], $info['gradient'][1] + $y, $info['gradient'][2], $info['gradient'][1] + $y + 1, $color);
+    imagefilledrectangle($target, $info['gradient'][0], $info['gradient'][1] + $y, $info['gradient'][0] + $info['gradient'][2], $info['gradient'][1] + $y + 1, $color);
   }
 
   // Blend over template.
@@ -401,6 +424,9 @@
     imagedestroy($slice);
     $paths['files'][] = $image;
 
+    // Set standard file permissions for webserver-generated files
+    @chmod(realpath($image), 0664);
+
     // Build before/after map of image paths.
     $paths['map'][$file] = $base;
   }
diff -Naur drupal-5.0/modules/comment/comment.css drupal-5.23/modules/comment/comment.css
--- drupal-5.0/modules/comment/comment.css	2006-10-15 21:57:06.000000000 +0200
+++ drupal-5.23/modules/comment/comment.css	2007-07-24 20:38:58.000000000 +0200
@@ -1,3 +1,11 @@
+/* $Id: comment.css,v 1.1.2.2 2007/07/24 18:38:58 drumm Exp $ */
+
 .indented {
   margin-left: 25px;
 }
+.comment-unpublished {
+  background-color: #fff4f4;
+}
+.preview .comment {
+  background-color: #ffffea;
+}
diff -Naur drupal-5.0/modules/comment/comment.info drupal-5.23/modules/comment/comment.info
--- drupal-5.0/modules/comment/comment.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/comment/comment.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/comment/comment.install drupal-5.23/modules/comment/comment.install
--- drupal-5.0/modules/comment/comment.install	2006-12-13 23:44:54.000000000 +0100
+++ drupal-5.23/modules/comment/comment.install	2007-06-20 09:14:21.000000000 +0200
@@ -1,11 +1,26 @@
 <?php
-// $Id: comment.install,v 1.2 2006/12/13 22:44:54 unconed Exp $
+// $Id: comment.install,v 1.2.2.1 2007/06/20 07:14:21 drumm Exp $
 
 /**
  * Implementation of hook_enable().
  */
 function comment_enable() {
   // Insert records into the node_comment_statistics for nodes that are missing.
-  db_query_temporary("SELECT n.nid, n.created, n.uid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE c.comment_count IS NULL", 'missing_nids');
-  db_query("INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) SELECT n.nid, n.created, NULL, n.uid, 0 FROM missing_nids n");
+  db_query_temporary("SELECT n.nid, n.changed, n.uid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE c.comment_count IS NULL", 'missing_nids');
+  db_query("INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) SELECT n.nid, n.changed, NULL, n.uid, 0 FROM missing_nids n");
+}
+
+/**
+ * Changed node_comment_statistics to use node->changed to avoid future
+ * timestamps.
+ */
+function comment_update_1() {
+  // Change any future last comment timestamps to now.
+  db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE last_comment_timestamp > %d', time(), time());
+
+  // Unstuck node indexing timestamp if needed.
+  if (($last = variable_get('node_cron_last', FALSE)) !== FALSE) {
+    variable_set('node_cron_last', min(time(), $last));
+  }
+  return array();
 }
diff -Naur drupal-5.0/modules/comment/comment.module drupal-5.23/modules/comment/comment.module
--- drupal-5.0/modules/comment/comment.module	2007-01-03 12:32:38.000000000 +0100
+++ drupal-5.23/modules/comment/comment.module	2010-08-11 22:37:49.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: comment.module,v 1.520 2007/01/03 11:32:38 dries Exp $
+// $Id: comment.module,v 1.520.2.15 2010/08/11 20:37:49 drumm Exp $
 
 /**
  * @file
@@ -249,7 +249,7 @@
   // Select the $number nodes (visible to the current user) with the most
   // recent comments. This is efficient due to the index on
   // last_comment_timestamp.
-  $result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node_comment_statistics} n WHERE n.comment_count > 0 ORDER BY n.last_comment_timestamp DESC"), 0, $number);
+  $result = db_query_range(db_rewrite_sql("SELECT nc.nid FROM {node_comment_statistics} nc WHERE nc.comment_count > 0 ORDER BY nc.last_comment_timestamp DESC", 'nc'), 0, $number);
 
   $nids = array();
   while ($row = db_fetch_object($result)) {
@@ -260,7 +260,7 @@
   if (!empty($nids)) {
     // From among the comments on the nodes selected in the first query,
     // find the $number most recent comments.
-    $result = db_query_range('SELECT c.nid, c.subject, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.nid IN ('. implode(',', $nids) .') AND n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC', COMMENT_PUBLISHED, 0, $number);
+    $result = db_query_range('SELECT c.nid, c.subject, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.nid IN ('. implode(',', $nids) .') AND n.status = 1 AND c.status = %d ORDER BY c.cid DESC', COMMENT_PUBLISHED, 0, $number);
     while ($comment = db_fetch_object($result)) {
       $comments[] = $comment;
     }
@@ -415,7 +415,7 @@
       break;
 
     case 'insert':
-      db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->created, $node->uid);
+      db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->changed, $node->uid);
       break;
 
     case 'delete':
@@ -575,7 +575,7 @@
   global $user;
 
   if ($op == 'edit') {
-    return ($user->uid && $user->uid == $comment->uid && comment_num_replies($comment->cid) == 0) || user_access('administer comments');
+    return ($user->uid && $user->uid == $comment->uid && comment_num_replies($comment->cid) == 0 && $comment->status == COMMENT_PUBLISHED) || user_access('administer comments');
   }
 }
 
@@ -723,7 +723,7 @@
         }
 
         // Add the comment to database.
-        $status = user_access('post comments without approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED;
+        $edit['status'] = user_access('post comments without approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED;
         $roles = variable_get('comment_roles', array());
         $score = 0;
 
@@ -784,7 +784,7 @@
           $edit['name'] = $user->name;
         }
 
-        db_query("INSERT INTO {comments} (cid, nid, pid, uid, subject, comment, format, hostname, timestamp, status, score, users, thread, name, mail, homepage) VALUES (%d, %d, %d, %d, '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $edit['cid'], $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], $_SERVER['REMOTE_ADDR'], $edit['timestamp'], $status, $score, $users, $thread, $edit['name'], $edit['mail'], $edit['homepage']);
+        db_query("INSERT INTO {comments} (cid, nid, pid, uid, subject, comment, format, hostname, timestamp, status, score, users, thread, name, mail, homepage) VALUES (%d, %d, %d, %d, '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $edit['cid'], $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], $_SERVER['REMOTE_ADDR'], $edit['timestamp'], $edit['status'], $score, $users, $thread, $edit['name'], $edit['mail'], $edit['homepage']);
 
         _comment_update_node_statistics($edit['nid']);
 
@@ -800,7 +800,7 @@
 
       // Explain the approval queue if necessary, and then
       // redirect the user to the node he's commenting on.
-      if ($status == COMMENT_NOT_PUBLISHED) {
+      if ($edit['status'] == COMMENT_NOT_PUBLISHED) {
         drupal_set_message(t('Your comment has been queued for moderation by site administrators and will be published after approval.'));
       }
       return $edit['cid'];
@@ -981,7 +981,7 @@
 
       if ($order == COMMENT_ORDER_NEWEST_FIRST) {
         if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
-          $query .= ' ORDER BY c.timestamp DESC';
+          $query .= ' ORDER BY c.cid DESC';
         }
         else {
           $query .= ' ORDER BY c.thread DESC';
@@ -989,7 +989,7 @@
       }
       else if ($order == COMMENT_ORDER_OLDEST_FIRST) {
         if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
-          $query .= ' ORDER BY c.timestamp';
+          $query .= ' ORDER BY c.cid';
         }
         else {
 
@@ -1011,7 +1011,7 @@
 
       $divs = 0;
       $last_depth = 0;
-      drupal_add_css(drupal_get_path('module', 'comment') . '/comment.css');
+      drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
       while ($comment = db_fetch_object($result)) {
         $comment = drupal_unpack($comment);
         $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
@@ -1055,8 +1055,9 @@
       }
     }
 
-    // If enabled, show new comment form.
-    if (user_access('post comments') && node_comment_mode($nid) == COMMENT_NODE_READ_WRITE && (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW)) {
+    // If enabled, show new comment form if it's not already being displayed.
+    $reply = arg(0) == 'comment' && arg(1) == 'reply';
+    if (user_access('post comments') && node_comment_mode($nid) == COMMENT_NODE_READ_WRITE && (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW) && !$reply) {
       $output .= comment_form_box(array('nid' => $nid), t('Post new comment'));
     }
 
@@ -1075,23 +1076,8 @@
 
   $output = '';
 
-  // We'll only delete if the user has confirmed the
-  // deletion using the form in our else clause below.
-  if (is_object($comment) && is_numeric($comment->cid) && $_POST['confirm']) {
-    drupal_set_message(t('The comment and all its replies have been deleted.'));
-
-    // Delete comment and its replies.
-    _comment_delete_thread($comment);
-
-    _comment_update_node_statistics($comment->nid);
-
-    // Clear the cache so an anonymous user sees that his comment was deleted.
-    cache_clear_all();
-
-    drupal_goto("node/$comment->nid");
-  }
-  else if (is_object($comment) && is_numeric($comment->cid)) {
-    $output = drupal_get_form('comment_confirm_delete', $comment->subject, $comment->nid);
+  if (is_object($comment) && is_numeric($comment->cid)) {
+    $output = drupal_get_form('comment_confirm_delete', $comment);
   }
   else {
     drupal_set_message(t('The comment no longer exists.'));
@@ -1100,16 +1086,38 @@
   return $output;
 }
 
-function comment_confirm_delete($subject, $nid) {
+function comment_confirm_delete($comment) {
+
+  $form = array();
+  $form['comment'] = array(
+    '#type' => 'value',
+    '#value' => $comment,
+  );
+
   return confirm_form(
-    array(),
-    t('Are you sure you want to delete the comment %title?', array('%title' => $subject)),
-    'node/'. $nid,
+    $form,
+    t('Are you sure you want to delete the comment %title?', array('%title' => $comment->subject)),
+    'node/'. $comment->nid,
     t('Any replies to this comment will be lost. This action cannot be undone.'),
     t('Delete'),
     t('Cancel'));
 }
 
+function comment_confirm_delete_submit($form_id, $form_values) {
+  $comment = $form_values['comment'];
+
+  // Delete comment and its replies.
+  _comment_delete_thread($comment);
+  _comment_update_node_statistics($comment->nid);
+ // Clear the cache so an anonymous user sees that his comment was deleted.
+  cache_clear_all();
+
+  drupal_set_message(t('The comment and all its replies have been deleted.'));
+
+  return "node/$comment->nid";
+}
+
+
 /**
  * Comment operations. We offer different update operations depending on
  * which comment administration page we're on.
@@ -1224,7 +1232,7 @@
     }
     cache_clear_all();
     drupal_set_message(t('The update has been performed.'));
-    drupal_goto('admin/content/comment');
+    return 'admin/content/comment';
   }
 }
 
@@ -1524,7 +1532,7 @@
   else if (variable_get('comment_anonymous', COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MUST_CONTACT) {
     $form['name'] = array('#type' => 'textfield', '#title' => t('Your name'), '#maxlength' => 60, '#size' => 30, '#default_value' => $edit['name'] ? $edit['name'] : variable_get('anonymous', t('Anonymous')), '#required' => TRUE);
 
-    $form['mail'] = array('#type' => 'textfield', '#title' => t('E-mail'), '#maxlength' => 64, '#size' => 30, '#default_value' => $edit['mail'],'#description' => t('The content of this field is kept private and will not be shown publicly.'), '#required' => TRUE);
+    $form['mail'] = array('#type' => 'textfield', '#title' => t('E-mail'), '#maxlength' => 64, '#size' => 30, '#default_value' => $edit['mail'], '#description' => t('The content of this field is kept private and will not be shown publicly.'), '#required' => TRUE);
 
     $form['homepage'] = array('#type' => 'textfield', '#title' => t('Homepage'), '#maxlength' => 255, '#size' => 30, '#default_value' => $edit['homepage']);
   }
@@ -1545,7 +1553,7 @@
   $form['uid'] = array('#type' => 'value', '#value' => $edit['uid']);
 
   $form['preview'] = array('#type' => 'button', '#value' => t('Preview comment'), '#weight' => 19);
-  $form['#token'] = 'comment' . $edit['nid'] . $edit['pid'];
+  $form['#token'] = 'comment'. $edit['nid'] . $edit['pid'];
 
   // Only show post button if preview is optional or if we are in preview mode.
   // We show the post button in preview mode even if there are form errors so that
@@ -1558,10 +1566,6 @@
     $form['#after_build'] = array('comment_form_add_preview');
   }
 
-  if ($_REQUEST['destination']) {
-    $form['#attributes']['destination'] = $_REQUEST['destination'];
-  }
-
   if (empty($edit['cid']) && empty($edit['pid'])) {
     $form['#action'] = url('comment/reply/'. $edit['nid']);
   }
@@ -1582,24 +1586,26 @@
 
   $output = '';
 
-  comment_validate($edit);
-  $comment = (object)_comment_form_submit($edit);
-
-  // Attach the user and time information.
-  if ($edit['author']) {
-    $account = user_load(array('name' => $edit['author']));
-  }
-  elseif ($user->uid && !isset($edit['is_anonymous'])) {
-    $account = $user;
-  }
-  if ($account) {
-    $comment->uid = $account->uid;
-    $comment->name = check_plain($account->name);
-  }
-  $comment->timestamp = $edit['timestamp'] ? $edit['timestamp'] : time();
-
-  // Preview the comment with security check.
+  // Invoke full validation for the form, to protect against cross site
+  // request forgeries (CSRF) and setting arbitrary values for fields such as
+  // the input format. Preview the comment only when form validation does not
+  // set any errors.
+  drupal_validate_form($form['form_id']['#value'], $form);
   if (!form_get_errors()) {
+    $comment = (object)_comment_form_submit($edit);
+
+    // Attach the user and time information.
+    if ($edit['author']) {
+      $account = user_load(array('name' => $edit['author']));
+    }
+    elseif ($user->uid && !isset($edit['is_anonymous'])) {
+      $account = $user;
+    }
+    if ($account) {
+      $comment->uid = $account->uid;
+      $comment->name = check_plain($account->name);
+    }
+    $comment->timestamp = $edit['timestamp'] ? $edit['timestamp'] : time();
     $output .= theme('comment_view', $comment);
   }
   $form['comment_preview'] = array(
@@ -1618,7 +1624,8 @@
     $output .= theme('comment_view', $comment);
   }
   else {
-    $form['#suffix'] = node_view(node_load($edit['nid']));
+    $suffix = empty($form['#suffix']) ? '' : $form['#suffix'];
+    $form['#suffix'] = $suffix . node_view(node_load($edit['nid']));
     $edit['pid'] = 0;
   }
 
@@ -1649,7 +1656,7 @@
     // 2) Strip out all HTML tags
     // 3) Convert entities back to plain-text.
     // Note: format is checked by check_markup().
-    $form_values['subject'] = trim(truncate_utf8(decode_entities(strip_tags(check_markup($form_values['comment'], $form_values['format']))), 29, TRUE));
+    $form_values['subject'] = truncate_utf8(trim(decode_entities(strip_tags(check_markup($form_values['comment'], $form_values['format'])))), 29, TRUE);
     // Edge cases where the comment body is populated only by HTML tags will
     // require a default subject.
     if ($form_values['subject'] == '') {
@@ -1765,7 +1772,7 @@
 
 function theme_comment($comment, $links = array()) {
   $output  = '<div class="comment'. ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') .'">';
-  $output .= '<div class="subject">'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") . ' ' . theme('mark', $comment->new) ."</div>\n";
+  $output .= '<div class="subject">'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") .' '. theme('mark', $comment->new) ."</div>\n";
   $output .= '<div class="credit">'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."</div>\n";
   $output .= '<div class="body">'. $comment->comment .'</div>';
   $output .= '<div class="links">'. theme('links', $links) .'</div>';
@@ -1775,7 +1782,7 @@
 
 function theme_comment_folded($comment) {
   $output  = "<div class=\"comment-folded\">\n";
-  $output .= ' <span class="subject">'. l($comment->subject, comment_node_url() .'/'. $comment->cid, NULL, NULL, "comment-$comment->cid") . ' '. theme('mark', $comment->new) .'</span> ';
+  $output .= ' <span class="subject">'. l($comment->subject, comment_node_url() .'/'. $comment->cid, NULL, NULL, "comment-$comment->cid") .' '. theme('mark', $comment->new) .'</span> ';
   $output .= '<span class="credit">'. t('by') .' '. theme('username', $comment) ."</span>\n";
   $output .= "</div>\n";
   return $output;
@@ -1802,23 +1809,33 @@
 
 function theme_comment_post_forbidden($nid) {
   global $user;
-  if ($user->uid) {
-    return t("you can't post comments");
-  }
-  else {
-    // we cannot use drupal_get_destination() because these links sometimes appear on /node and taxo listing pages
-    if (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
-      $destination = "destination=". drupal_urlencode("comment/reply/$nid#comment_form");
-    }
-    else {
-      $destination = "destination=". drupal_urlencode("node/$nid#comment_form");
-    }
+  static $authenticated_post_comments;
 
-    if (variable_get('user_register', 1)) {
-      return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', $destination), '@register' => url('user/register', $destination)));
+  if (!$user->uid) {
+    if (!isset($authenticated_post_comments)) {
+      // We only output any link if we are certain, that users get permission
+      // to post comments by logging in. We also locally cache this information.
+      $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval'));
     }
-    else {
-      return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', $destination)));
+
+    if ($authenticated_post_comments) {
+      // We cannot use drupal_get_destination() because these links
+      // sometimes appear on /node and taxonomy listing pages.
+      if (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
+        $destination = 'destination='. drupal_urlencode("comment/reply/$nid#comment-form");
+      }
+      else {
+        $destination = 'destination='. drupal_urlencode("node/$nid#comment-form");
+      }
+
+      if (variable_get('user_register', 1)) {
+        // Users can register themselves.
+        return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', $destination), '@register' => url('user/register', $destination)));
+      }
+      else {
+        // Only admins can add new users, no public registration.
+        return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', $destination)));
+      }
     }
   }
 }
@@ -1827,7 +1844,7 @@
  * Allow themable wrapping of all comments.
  */
 function theme_comment_wrapper($content) {
-  return '<div id="comments">' . $content . '</div>';
+  return '<div id="comments">'. $content .'</div>';
 }
 
 function _comment_delete_thread($comment) {
diff -Naur drupal-5.0/modules/contact/contact.info drupal-5.23/modules/contact/contact.info
--- drupal-5.0/modules/contact/contact.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/contact/contact.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/contact/contact.module drupal-5.23/modules/contact/contact.module
--- drupal-5.0/modules/contact/contact.module	2007-01-10 16:17:51.000000000 +0100
+++ drupal-5.23/modules/contact/contact.module	2009-12-16 21:46:31.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: contact.module,v 1.74 2007/01/10 15:17:51 dries Exp $
+// $Id: contact.module,v 1.74.2.3 2009/12/16 20:46:31 drumm Exp $
 
 /**
  * @file
@@ -27,7 +27,7 @@
         $menu_note = '';
       }
       $output .= '<p>'. t('The contact module also adds a <a href="@menu-settings">menu item</a> (disabled by default) to the navigation block.', array('@menu-settings' => url('admin/build/menu'))) .' '. $menu_note .'</p>';
-      return($output);
+      return $output;
   }
 }
 
@@ -145,7 +145,7 @@
   $result = db_query('SELECT cid, category, recipients, selected FROM {contact} ORDER BY weight, category');
   $rows = array();
   while ($category = db_fetch_object($result)) {
-    $rows[] = array($category->category, $category->recipients, ($category->selected ? t('Yes') : t('No')), l(t('edit'), 'admin/build/contact/edit/'. $category->cid), l(t('delete'), 'admin/build/contact/delete/'. $category->cid));
+    $rows[] = array(check_plain($category->category), check_plain($category->recipients), ($category->selected ? t('Yes') : t('No')), l(t('edit'), 'admin/build/contact/edit/'. $category->cid), l(t('delete'), 'admin/build/contact/delete/'. $category->cid));
   }
   $header = array(t('Category'), t('Recipients'), t('Selected'), array('data' => t('Operations'), 'colspan' => 2));
 
@@ -227,7 +227,7 @@
     db_query('UPDATE {contact} SET selected = 0');
   }
   $recipients = explode(',', $form_values['recipients']);
-  foreach ($recipients as $key=>$recipient) {
+  foreach ($recipients as $key => $recipient) {
     // E-mail address validation has already been done in _validate.
     $recipients[$key] = trim($recipient);
   }
@@ -428,7 +428,7 @@
 
   if (count($categories) > 0) {
     $form['#token'] = $user->name . $user->mail;
-    $form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave us a message using the contact form below.'))));
+    $form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave a message using the contact form below.'))));
     $form['name'] = array('#type' => 'textfield',
       '#title' => t('Your name'),
       '#maxlength' => 255,
@@ -547,6 +547,5 @@
   drupal_set_message(t('Your message has been sent.'));
 
   // Jump to home page rather than back to contact page to avoid contradictory messages if flood control has been activated.
-  return('');
+  return '';
 }
-
diff -Naur drupal-5.0/modules/drupal/drupal.info drupal-5.23/modules/drupal/drupal.info
--- drupal-5.0/modules/drupal/drupal.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/drupal/drupal.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/filter/filter.info drupal-5.23/modules/filter/filter.info
--- drupal-5.0/modules/filter/filter.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/filter/filter.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - required
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/filter/filter.module drupal-5.23/modules/filter/filter.module
--- drupal-5.0/modules/filter/filter.module	2007-01-12 08:27:21.000000000 +0100
+++ drupal-5.23/modules/filter/filter.module	2009-06-03 19:52:13.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: filter.module,v 1.160 2007/01/12 07:27:21 unconed Exp $
+// $Id: filter.module,v 1.160.2.14 2009/06/03 17:52:13 drumm Exp $
 
 /**
  * @file
@@ -159,9 +159,9 @@
         if ($allowed_html = variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>')) {
           switch ($long) {
             case 0:
-              return t('Allowed HTML tags') .': '. check_plain($allowed_html);
+              return t('Allowed HTML tags: @tags', array('@tags' => $allowed_html));
             case 1:
-              $output = '<p>'. t('Allowed HTML tags') .': '. check_plain($allowed_html) .'</p>';
+              $output = '<p>'. t('Allowed HTML tags: @tags', array('@tags' => $allowed_html)) .'</p>';
               if (!variable_get("filter_html_help_$format", 1)) {
                 return $output;
               }
@@ -604,6 +604,9 @@
 
   if (!empty($form)) {
     $form = system_settings_form($form);
+    $form['format'] = array('#type' => 'hidden', '#value' => $format);
+    $form['#submit']['system_settings_form_submit'] = array();
+    $form['#submit']['filter_admin_configure_submit'] = array();
   }
   else {
     $form['error'] = array('#value' => t('No settings are available.'));
@@ -613,6 +616,13 @@
 }
 
 /**
+ * Clear the filter's cache when configuration settings are saved.
+ */
+function filter_admin_configure_submit($form_id, $form_values) {
+  cache_clear_all($form_values['format'] .':', 'cache_filter', TRUE);
+}
+
+/**
  * Retrieve a list of input formats.
  */
 function filter_formats() {
@@ -699,13 +709,20 @@
   static $filters = array();
 
   if (!isset($filters[$format])) {
-    $filters[$format] = array();
     $result = db_query("SELECT * FROM {filters} WHERE format = %d ORDER BY weight ASC", $format);
-    while ($filter = db_fetch_object($result)) {
-      $list = module_invoke($filter->module, 'filter', 'list');
-      if (isset($list) && is_array($list) && isset($list[$filter->delta])) {
-        $filter->name = $list[$filter->delta];
-        $filters[$format][$filter->module .'/'. $filter->delta] = $filter;
+    if (db_num_rows($result) == 0 && !db_result(db_query("SELECT 1 FROM {filter_formats} WHERE format = %d", $format))) {
+      // The format has no filters and does not exist, use the default input
+      // format.
+      $filters[$format] = filter_list_format(variable_get('filter_default_format', 1));
+    }
+    else {
+      $filters[$format] = array();
+      while ($filter = db_fetch_object($result)) {
+        $list = module_invoke($filter->module, 'filter', 'list');
+        if (isset($list) && is_array($list) && isset($list[$filter->delta])) {
+          $filter->name = $list[$filter->delta];
+          $filters[$format][$filter->module .'/'. $filter->delta] = $filter;
+        }
       }
     }
   }
@@ -930,13 +947,12 @@
         $output .= '<strong>'. $name .'</strong>:<br />';
       }
 
-      $tips = '';
-      foreach ($tiplist as $tip) {
-        $tips .= '<li'. ($long ? ' id="filter-'. str_replace("/", "-", $tip['id']) .'">' : '>') . $tip['tip'] . '</li>';
-      }
-
-      if ($tips) {
-        $output .= "<ul class=\"tips\">$tips</ul>";
+      if (count($tiplist) > 0) {
+        $output .= '<ul class="tips">';
+        foreach ($tiplist as $tip) {
+          $output .= '<li'. ($long ? ' id="filter-'. str_replace("/", "-", $tip['id']) .'">' : '>') . $tip['tip'] .'</li>';
+        }
+        $output .= '</ul>';
       }
 
       if ($multiple) {
@@ -1048,7 +1064,7 @@
     '#title' => t('Allowed HTML tags'),
     '#default_value' => variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>'),
     '#size' => 64,
-    '#maxlength' => 255,
+    '#maxlength' => 1024,
     '#description' => t('If "Strip disallowed tags" is selected, optionally specify tags which should not be stripped. JavaScript event attributes are always stripped.'),
   );
   $form['filter_html']["filter_html_help_$format"] = array(
@@ -1171,13 +1187,13 @@
  */
 function _filter_autop($text) {
   // All block level tags
-  $block = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|p|h[1-6])';
+  $block = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|p|h[1-6]|hr)';
 
   // Split at <pre>, <script>, <style> and </pre>, </script>, </style> tags.
   // We don't apply any processing to the contents of these tags to avoid messing
   // up code. We look for matched pairs and allow basic nesting. For example:
   // "processed <pre> ignored <script> ignored </script> ignored </pre> processed"
-  $chunks = preg_split('@(</?(?:pre|script|style)[^>]*>)@i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
+  $chunks = preg_split('@(</?(?:pre|script|style|object)[^>]*>)@i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
   // Note: PHP ensures the array consists of alternating delimiters and literals
   // and begins and ends with a literal (inserting NULL as required).
   $ignore = FALSE;
@@ -1207,7 +1223,7 @@
       $chunk = preg_replace('!(</'. $block .'>)!', "$1\n\n", $chunk); // Space things out a little
       $chunk = preg_replace("/\n\n+/", "\n\n", $chunk); // take care of duplicates
       $chunk = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $chunk); // make paragraphs, including one at the end
-      $chunk = preg_replace('|<p>\s*?</p>\n|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace
+      $chunk = preg_replace('|<p>\s*</p>\n|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace
       $chunk = preg_replace("|<p>(<li.+?)</p>|", "$1", $chunk); // problem with nested lists
       $chunk = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $chunk);
       $chunk = str_replace('</blockquote></p>', '</p></blockquote>', $chunk);
@@ -1234,7 +1250,7 @@
  * for scripts and styles.
  */
 function filter_xss_admin($string) {
-  return filter_xss($string, array('a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'object', 'ol', 'p', 'param', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var'));
+  return filter_xss($string, array('a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'ol', 'p', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var'));
 }
 
 /**
@@ -1259,6 +1275,11 @@
  *   The format to use.
  */
 function filter_xss($string, $allowed_tags = array('a', 'em', 'strong', 'cite', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd')) {
+  // Only operate on valid UTF-8 strings. This is necessary to prevent cross
+  // site scripting issues on Internet Explorer 6.
+  if (!drupal_validate_utf8($string)) {
+    return '';
+  }
   // Store the input format
   _filter_xss_split($allowed_tags, TRUE);
   // Remove NUL characters (ignored by some browsers)
@@ -1280,7 +1301,7 @@
     (
     <(?=[^a-zA-Z!/])  # a lone <
     |                 # or
-    <[^>]*.(>|$)      # a string that starts with a <, up until the > or the end of the string
+    <[^>]*(>|$)       # a string that starts with a <, up until the > or the end of the string
     |                 # or
     >                 # just a >
     )%x', '_filter_xss_split', $string);
@@ -1493,8 +1514,9 @@
       if (preg_match('![/?#]!', $protocol)) {
         break;
       }
+      // Per RFC2616, section 3.2.3 (URI Comparison) scheme comparison must be case-insensitive.
       // Check if this is a disallowed protocol.
-      if (!isset($allowed_protocols[$protocol])) {
+      if (!isset($allowed_protocols[strtolower($protocol)])) {
         $string = substr($string, $colonpos + 1);
       }
     }
diff -Naur drupal-5.0/modules/forum/forum.info drupal-5.23/modules/forum/forum.info
--- drupal-5.0/modules/forum/forum.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/forum/forum.info	2010-08-11 22:46:30.000000000 +0200
@@ -5,7 +5,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/forum/forum.install drupal-5.23/modules/forum/forum.install
--- drupal-5.0/modules/forum/forum.install	2006-09-01 09:40:08.000000000 +0200
+++ drupal-5.23/modules/forum/forum.install	2008-07-06 02:07:13.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: forum.install,v 1.6 2006/09/01 07:40:08 drumm Exp $
+// $Id: forum.install,v 1.6.2.1 2008/07/06 00:07:13 drumm Exp $
 
 /**
  * Implementation of hook_install().
@@ -35,7 +35,6 @@
  */
 function forum_uninstall() {
   db_query('DROP TABLE {forum}');
-  db_query("DELETE FROM {node} WHERE type = 'forum'");
   variable_del('forum_containers');
   variable_del('forum_nav_vocabulary');
   variable_del('forum_hot_topic');
diff -Naur drupal-5.0/modules/forum/forum.module drupal-5.23/modules/forum/forum.module
--- drupal-5.0/modules/forum/forum.module	2007-01-10 16:17:51.000000000 +0100
+++ drupal-5.23/modules/forum/forum.module	2009-07-01 22:52:11.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: forum.module,v 1.375 2007/01/10 15:17:51 dries Exp $
+// $Id: forum.module,v 1.375.2.9 2009/07/01 20:52:11 drumm Exp $
 
 /**
  * @file
@@ -89,11 +89,6 @@
         'type' => MENU_CALLBACK);
     }
   }
-  else {
-    // Add the CSS for this module
-    // We put this in !$may_cache so it's only added once per request
-    drupal_add_css(drupal_get_path('module', 'forum') .'/forum.css');
-  }
 
   return $items;
 }
@@ -259,7 +254,7 @@
         switch ($delta) {
           case 0:
             $title = t('Active forum topics');
-            $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type = 'forum' ORDER BY l.last_comment_timestamp DESC");
+            $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type = 'forum' ORDER BY l.last_comment_timestamp DESC");
             $result = db_query_range($sql, 0, variable_get('forum_block_num_0', '5'));
             if (db_num_rows($result)) {
               $content = node_title_list($result);
@@ -292,6 +287,7 @@
  * Implementation of hook_view().
  */
 function forum_view(&$node, $teaser = FALSE, $page = FALSE) {
+  drupal_add_css(drupal_get_path('module', 'forum') .'/forum.css');
   if ($page) {
     $vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
     // Breadcrumb navigation
@@ -325,7 +321,7 @@
  */
 function forum_submit(&$node) {
   // Make sure all fields are set properly:
-  $node->icon = $node->icon ? $node->icon : '';
+  $node->icon = !empty($node->icon) ? $node->icon : '';
 
   if ($node->taxonomy) {
     // Get the forum terms from the (cached) tree
@@ -392,7 +388,7 @@
   $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#default_value' => $node->title, '#required' => TRUE, '#weight' => -5);
 
   if ($node->nid) {
-    $forum_terms = taxonomy_node_get_terms_by_vocabulary(_forum_get_vid(), $node->nid);
+    $forum_terms = taxonomy_node_get_terms_by_vocabulary($node->nid, _forum_get_vid());
     // if editing, give option to leave shadows
     $shadow = (count($forum_terms) > 1);
     $form['shadow'] = array('#type' => 'checkbox', '#title' => t('Leave shadow copy'), '#default_value' => $shadow, '#description' => t('If you move this topic, you can leave a link in the old forum to the new forum.'));
@@ -590,10 +586,10 @@
   if ($tree) {
     foreach ($tree as $term) {
       if (in_array($term->tid, variable_get('forum_containers', array()))) {
-        $rows[] = array(str_repeat(' -- ', $term->depth) .' '. l(check_plain($term->name), 'forum/'. $term->tid), l(t('edit container'), 'admin/content/forum/edit/container/'. $term->tid));
+        $rows[] = array(str_repeat(' -- ', $term->depth) .' '. l($term->name, 'forum/'. $term->tid), l(t('edit container'), 'admin/content/forum/edit/container/'. $term->tid));
       }
       else {
-        $rows[] = array(str_repeat(' -- ', $term->depth) .' '. l(check_plain($term->name), 'forum/'. $term->tid), l(t('edit forum'), 'admin/content/forum/edit/forum/'. $term->tid));
+        $rows[] = array(str_repeat(' -- ', $term->depth) .' '. l($term->name, 'forum/'. $term->tid), l(t('edit forum'), 'admin/content/forum/edit/forum/'. $term->tid));
        }
 
     }
@@ -649,18 +645,8 @@
   return array('#type' => 'select', '#title' => $title, '#default_value' => $parent, '#options' => $options, '#description' => $description, '#required' => TRUE);
 }
 
-function forum_link_alter(&$node, &$links) {
-  foreach ($links as $module => $link) {
-    if (strstr($module, 'taxonomy_term')) {
-      // Link back to the forum and not the taxonomy term page. We'll only
-      // do this if the taxonomy term in question belongs to forums.
-      $tid = str_replace('taxonomy/term/', '', $link['href']);
-      $term = taxonomy_get_term($tid);
-      if ($term->vid == _forum_get_vid()) {
-        $links[$module]['href'] = str_replace('taxonomy/term', 'forum', $link['href']);
-      }
-    }
-  }
+function forum_term_path($term) {
+  return 'forum/'. $term->tid;
 }
 
 /**
@@ -674,7 +660,7 @@
     if (!$vid) {
       // Create the forum vocabulary. Assign the vocabulary a low weight so
       // it will appear first in forum topic create and edit forms.
-      $edit = array('name' => 'Forums', 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'forum', 'weight' => -10, 'nodes' => array('forum' => 1));
+      $edit = array('name' => t('Forums'), 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'forum', 'weight' => -10, 'nodes' => array('forum' => 1));
       taxonomy_save_vocabulary($edit);
       $vid = $edit['vid'];
     }
@@ -798,7 +784,7 @@
   $sql_count = db_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum'");
 
   $result = pager_query($sql, $forum_per_page, 0, $sql_count, $tid);
-
+  $topics = array();
   while ($topic = db_fetch_object($result)) {
     if ($user->uid) {
       // folder is new if topic is new or there are new comments since last visit
@@ -847,22 +833,22 @@
  * Menu callback; prints a forum listing.
  */
 function forum_page($tid = 0) {
-  if (module_exists('taxonomy') && module_exists('comment')) {
-    $forum_per_page = variable_get('forum_per_page', 25);
-    $sortby = variable_get('forum_order', 1);
+  if (!is_numeric($tid)) {
+    return MENU_NOT_FOUND;
+  }
+  $tid = (int)$tid;
 
-    $forums = forum_get_forums($tid);
-    $parents = taxonomy_get_parents_all($tid);
-    if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
-      $topics = forum_get_topics($tid, $sortby, $forum_per_page);
-    }
+  drupal_add_css(drupal_get_path('module', 'forum') .'/forum.css');
+  $forum_per_page = variable_get('forum_per_page', 25);
+  $sortby = variable_get('forum_order', 1);
 
-    return theme('forum_display', $forums, $topics, $parents, $tid, $sortby, $forum_per_page);
-  }
-  else {
-    drupal_set_message(t('The forum module requires both the taxonomy module and the comment module to be enabled and configured.'), 'error');
-    return ' ';
+  $forums = forum_get_forums($tid);
+  $parents = taxonomy_get_parents_all($tid);
+  if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
+    $topics = forum_get_topics($tid, $sortby, $forum_per_page);
   }
+
+  return theme('forum_display', $forums, $topics, $parents, $tid, $sortby, $forum_per_page);
 }
 
 /**
@@ -991,7 +977,7 @@
  */
 function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page) {
   global $forum_topic_list_header;
-
+  $rows = array();
   if ($topics) {
 
     foreach ($topics as $topic) {
@@ -1092,7 +1078,7 @@
       // Word break (a is an inline element)
       $output .= ' ';
     }
-    if ($next) {
+    if (!empty($next)) {
       $output .= l($next->title . t(' â€º'), 'node/'. $next->nid, array('class' => 'topic-next', 'title' => t('Go to next forum topic')));
     }
 
diff -Naur drupal-5.0/modules/help/help.info drupal-5.23/modules/help/help.info
--- drupal-5.0/modules/help/help.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/help/help.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/help/help.module drupal-5.23/modules/help/help.module
--- drupal-5.0/modules/help/help.module	2006-12-23 23:06:05.000000000 +0100
+++ drupal-5.23/modules/help/help.module	2007-10-16 08:57:22.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: help.module,v 1.69 2006/12/23 22:06:05 dries Exp $
+// $Id: help.module,v 1.69.2.1 2007/10/16 06:57:22 drumm Exp $
 
 /**
  * @file
@@ -126,9 +126,14 @@
       $output .= $temp;
     }
 
+    // Only print list of administration pages if the module in question has
+    // any such pages associated to it.
     $admin_tasks = system_get_module_admin_tasks($name);
-    ksort($admin_tasks);
-    $output .= theme('item_list', $admin_tasks, t('@module administration pages', array('@module' => $module['name'])));
+    if (!empty($admin_tasks)) {
+      ksort($admin_tasks);
+      $output .= theme('item_list', $admin_tasks, t('@module administration pages', array('@module' => $module['name'])));
+    }
+
   }
   return $output;
 }
diff -Naur drupal-5.0/modules/legacy/legacy.info drupal-5.23/modules/legacy/legacy.info
--- drupal-5.0/modules/legacy/legacy.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/legacy/legacy.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/legacy/legacy.module drupal-5.23/modules/legacy/legacy.module
--- drupal-5.0/modules/legacy/legacy.module	2006-11-21 21:14:18.000000000 +0100
+++ drupal-5.23/modules/legacy/legacy.module	2007-11-10 04:27:33.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: legacy.module,v 1.15 2006/11/21 20:14:18 dries Exp $
+// $Id: legacy.module,v 1.15.2.1 2007/11/10 03:27:33 drumm Exp $
 
 /**
  * @file
@@ -57,19 +57,19 @@
     // Map "node/view/52" to "node/52".
     $items[] = array('path' => 'node/view', 'title' => t('View'),
       'callback' => 'drupal_goto',
-      'callback arguments' => array('node/'. arg(2), NULL, NULL),
+      'callback arguments' => array('node/'. arg(2), NULL, NULL, 301),
       'access' => TRUE, 'type' => MENU_CALLBACK);
 
     // Map "book/view/52" to "node/52".
     $items[] = array('path' => 'book/view', 'title' => t('View'),
       'callback' => 'drupal_goto',
-      'callback arguments' => array('node/'. arg(2), NULL, NULL),
+      'callback arguments' => array('node/'. arg(2), NULL, NULL, 301),
       'access' => TRUE, 'type' => MENU_CALLBACK);
 
     // Map "user/view/52" to "user/52".
     $items[] = array('path' => 'user/view', 'title' => t('View'),
       'callback' => 'drupal_goto',
-      'callback arguments' => array('user/'. arg(2), NULL, NULL),
+      'callback arguments' => array('user/'. arg(2), NULL, NULL, 301),
       'access' => TRUE, 'type' => MENU_CALLBACK);
   }
 
diff -Naur drupal-5.0/modules/locale/locale.info drupal-5.23/modules/locale/locale.info
--- drupal-5.0/modules/locale/locale.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/locale/locale.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/locale/locale.install drupal-5.23/modules/locale/locale.install
--- drupal-5.0/modules/locale/locale.install	2006-11-14 07:20:40.000000000 +0100
+++ drupal-5.23/modules/locale/locale.install	2010-03-04 01:16:02.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: locale.install,v 1.7 2006/11/14 06:20:40 drumm Exp $
+// $Id: locale.install,v 1.7.2.1 2010/03/04 00:16:02 drumm Exp $
 
 /**
  * Implementation of hook_install().
@@ -85,3 +85,23 @@
   db_query('DROP TABLE {locales_source}');
   db_query('DROP TABLE {locales_target}');
 }
+
+/**
+ * Neutralize unsafe language names in the database.
+ */
+function locale_update_1() {
+  $ret = array();
+  $matches = db_result(db_query("SELECT 1 FROM {locales_meta} WHERE name LIKE '%<%' OR name LIKE '%>%'"));
+  if ($matches) {
+    $ret[] = update_sql("UPDATE {locales_meta} SET name = REPLACE(name, '<', '')");
+    $ret[] = update_sql("UPDATE {locales_meta} SET name = REPLACE(name, '>', '')");
+    drupal_set_message('The language name in English of all the existing custom languages of your site have been sanitized for security purposes. Visit the <a href="'. url('admin/settings/language') .'">Languages</a> page to check these and fix them if necessary.', 'warning');
+  }
+  // Check if some langcode values contain potentially dangerous characters and
+  // warn the user if so. These are not fixed since they are referenced in other
+  // tables (e.g. {node}).
+  if (db_result(db_query("SELECT 1 FROM {locales_meta} WHERE locale LIKE '%<%' OR locale LIKE '%>%' OR locale LIKE '%\"%' OR locale LIKE '%\\\\\%'"))) {
+    drupal_set_message('Some of your custom language code values contain invalid characters. You should examine the <a href="'. url('admin/settings/language') .'">Languages</a> page. These must be fixed manually.', 'error');
+  }
+  return $ret;
+}
diff -Naur drupal-5.0/modules/locale/locale.module drupal-5.23/modules/locale/locale.module
--- drupal-5.0/modules/locale/locale.module	2006-12-27 14:11:59.000000000 +0100
+++ drupal-5.23/modules/locale/locale.module	2010-03-04 01:16:02.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: locale.module,v 1.155 2006/12/27 13:11:59 drumm Exp $
+// $Id: locale.module,v 1.155.2.2 2010/03/04 00:16:02 drumm Exp $
 
 /**
  * @file
@@ -111,7 +111,7 @@
         'type' => MENU_CALLBACK);
       $items[] = array('path' => 'admin/settings/locale/string/delete/'. arg(5),
         'title' => t('Delete string'),
-        'callback' => 'locale_admin_string_delete',
+        'callback' => 'locale_admin_string_delete_page',
         'callback arguments' => array(arg(5)),
         'access' => $access,
         'type' => MENU_CALLBACK);
@@ -137,15 +137,17 @@
     if ($user->language == '') {
       $user->language = key($languages['name']);
     }
-    $languages['name'] = array_map('check_plain', array_map('t', $languages['name']));
+    foreach (array_map('t', $languages['name']) as $key => $value) {
+      $languages_name[check_plain($key)] = check_plain($value);
+    }
     $form['locale'] = array('#type' => 'fieldset',
       '#title' => t('Interface language settings'),
       '#weight' => 1,
     );
     $form['locale']['language'] = array('#type' => 'radios',
       '#title' => t('Language'),
-      '#default_value' => $user->language,
-      '#options' => $languages['name'],
+      '#default_value' => check_plain($user->language),
+      '#options' => $languages_name,
       '#description' => t('Selecting a different locale will change the interface language of the site.'),
     );
     return $form;
@@ -407,9 +409,29 @@
 }
 
 /**
- * Delete a string.
+ * String deletion confirmation page.
+ */
+function locale_admin_string_delete_page($lid) {
+  if ($source = db_fetch_object(db_query('SELECT * FROM {locales_source} WHERE lid = %d', $lid))) {
+    return drupal_get_form('locale_string_delete_form', $source);
+  }
+  else {
+    return drupal_not_found();
+  }
+}
+
+/**
+ * User interface for the string deletion confirmation screen.
+ */
+function locale_string_delete_form($source) {
+  $form['lid'] = array('#type' => 'value', '#value' => $source->lid);
+  return confirm_form($form, t('Are you sure you want to delete the string "%source"?', array('%source' => $source->source)), 'admin/build/translate/search', t('Deleting the string will remove all translations of this string in all languages. This action cannot be undone.'), t('Delete'), t('Cancel'));
+}
+
+/**
+ * Process string deletion submissions.
  */
-function locale_admin_string_delete($lid) {
+function locale_string_delete_form_submit($form_id, $form_values) {
   include_once './includes/locale.inc';
-  _locale_string_delete($lid);
+  _locale_string_delete($form_values['lid']);
 }
diff -Naur drupal-5.0/modules/menu/menu.info drupal-5.23/modules/menu/menu.info
--- drupal-5.0/modules/menu/menu.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/menu/menu.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/menu/menu.module drupal-5.23/modules/menu/menu.module
--- drupal-5.0/modules/menu/menu.module	2007-01-05 20:05:54.000000000 +0100
+++ drupal-5.23/modules/menu/menu.module	2009-02-26 07:56:26.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: menu.module,v 1.100 2007/01/05 19:05:54 dries Exp $
+// $Id: menu.module,v 1.100.2.4 2009/02/26 06:56:26 drumm Exp $
 
 /**
  * @file
@@ -68,7 +68,8 @@
       'type' => MENU_CALLBACK);
     $items[] = array('path' => 'admin/build/menu/item/disable',
       'title' => t('Disable menu item'),
-      'callback' => 'menu_disable_item',
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('menu_confirm_disable_item'),
       'access' => user_access('administer menu'),
       'type' => MENU_CALLBACK);
     $items[] = array('path' => 'admin/build/menu/item/delete',
@@ -175,7 +176,7 @@
   if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
     $item = array();
     if ($form['nid']['#value'] > 0) {
-      $item = db_fetch_array(db_query("SELECT * FROM {menu} WHERE path = 'node/%d'", $form['nid']['#value']));
+      $item = db_fetch_array(db_query("SELECT * FROM {menu} WHERE path = 'node/%d' ORDER BY mid", $form['nid']['#value']));
       if (isset($form['#post']['menu']) && is_array($form['#post']['menu'])) {
         $item = !is_array($item) ? $form['#post']['menu'] : (($form['#post']['op'] == t('Preview')) ? array_merge($item, $form['#post']['menu']) : array_merge($form['#post']['menu'], $item));
       }
@@ -356,6 +357,7 @@
     '#title' => t('Description'),
     '#default_value' => $item['description'],
     '#description' => t('The description displayed when hovering over a menu item.'),
+    '#maxlength' => 255,
   );
 
   if ($item['type'] & MENU_CREATED_BY_ADMIN) {
@@ -394,8 +396,9 @@
     '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
   );
 
-  // Always enable menu items (but not menus) when editing them.
-  if (!($item['type'] & MENU_IS_ROOT)) {
+  // Always enable menu items (but not menus) when editing them, unless already
+  // conditionally visible.
+  if (!($item['type'] & (MENU_IS_ROOT | MENU_VISIBLE_IF_HAS_CHILDREN))) {
     $item['type'] |= MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB;
   }
 
@@ -481,14 +484,24 @@
 
 /**
  * Menu callback; hide a menu item.
+ *
+ * Presents a confirmation form to protect against cross site request forgeries.
  */
-function menu_disable_item($mid) {
+function menu_confirm_disable_item($mid, $token = NULL) {
+  global $user;
   $item = menu_get_item($mid);
-  $type = $item['type'];
+  $form = array();
+  $form['mid'] = array('#type' => 'value', '#value' => $mid);
+  $form['item'] = array('#type' => 'value', '#value' => $item);
+  return confirm_form($form, t('Are you sure you want to disable the menu item %menu-item?', array('%menu-item' =>  $item['title'])), 'admin/build/menu', ' ', t('Disable'), t('Cancel'));
+}
+
+function menu_confirm_disable_item_submit($form_id, $form_values) {
+  $type = $form_values['item']['type'];
   $type &= ~MENU_VISIBLE_IN_TREE;
   $type &= ~MENU_VISIBLE_IN_BREADCRUMB;
   $type |= MENU_MODIFIED_BY_ADMIN;
-  db_query('UPDATE {menu} SET type = %d WHERE mid = %d', $type, $mid);
+  db_query('UPDATE {menu} SET type = %d WHERE mid = %d', $type, $form_values['mid']);
   drupal_set_message(t('The menu item has been disabled.'));
   drupal_goto('admin/build/menu');
 }
diff -Naur drupal-5.0/modules/node/content_types.inc drupal-5.23/modules/node/content_types.inc
--- drupal-5.0/modules/node/content_types.inc	2007-01-09 08:53:26.000000000 +0100
+++ drupal-5.23/modules/node/content_types.inc	2008-02-11 08:54:44.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: content_types.inc,v 1.24 2007/01/09 07:53:26 drumm Exp $
+// $Id: content_types.inc,v 1.24.2.4 2008/02/11 07:54:44 drumm Exp $
 
 /**
  * @file
@@ -18,7 +18,6 @@
   foreach ($names as $key => $name) {
     $type = $types[$key];
     if (function_exists($type->module .'_form')) {
-      $name = check_plain($name);
       $type_url_str = str_replace('_', '-', $type->type);
       // Populate the operations field.
       $operations = array();
@@ -194,6 +193,7 @@
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save content type'),
+    '#weight' => 40,
   );
 
   if ($type->custom) {
@@ -201,6 +201,7 @@
       $form['delete'] = array(
         '#type' => 'submit',
         '#value' => t('Delete content type'),
+        '#weight' => 45,
       );
     }
   }
@@ -208,6 +209,7 @@
     $form['reset'] = array(
       '#type' => 'submit',
       '#value' => t('Reset to defaults'),
+      '#weight' => 50,
     );
   }
 
@@ -224,9 +226,6 @@
 
   // Work out what the type was before the user submitted this form
   $old_type = trim($form_values['old_type']);
-  if (empty($old_type)) {
-    $old_type = $type->type;
-  }
 
   $types = node_get_types('names');
 
@@ -237,16 +236,18 @@
     if (!preg_match('!^[a-z0-9_]+$!', $type->type)) {
       form_set_error('type', t('The machine-readable name can only consist of lowercase letters, underscores, and numbers.'));
     }
-    // The type cannot be just the character '0', since elsewhere we check it using empty().
-    if ($type->type === '0') {
-      form_set_error('type', t("Invalid type. Please enter a type name other than '0' (the character zero)."));
+    // 'theme' conflicts with theme_node_form()
+    // 'add' and 'list' conflict with menu paths
+    // '0' is invalid, since elsewhere we check it using empty().
+    if (in_array($type->type, array('0', 'theme', 'add', 'list'))) {
+      form_set_error('type', t("Invalid machine-readable name. Please enter a name other than %invalid.", array('%invalid' => $type->type)));
     }
   }
 
   $names = array_flip($types);
 
   if (isset($names[$type->name]) && $names[$type->name] != $old_type) {
-    form_set_error('name', t('The human-readable name %name is already taken.', array('%name' => $names[$type->name])));
+    form_set_error('name', t('The human-readable name %name is already taken.', array('%name' => $type->name)));
   }
 }
 
diff -Naur drupal-5.0/modules/node/node.css drupal-5.23/modules/node/node.css
--- drupal-5.0/modules/node/node.css	2006-09-05 05:50:56.000000000 +0200
+++ drupal-5.23/modules/node/node.css	2007-07-24 20:38:58.000000000 +0200
@@ -1,9 +1,9 @@
-/* $Id: node.css,v 1.2 2006/09/05 03:50:56 unconed Exp $ */
+/* $Id: node.css,v 1.2.2.1 2007/07/24 18:38:58 drumm Exp $ */
 
-.node-unpublished, .comment-unpublished {
+.node-unpublished {
   background-color: #fff4f4;
 }
-.preview .node, .preview .comment {
+.preview .node {
   background-color: #ffffea;
 }
 #node-admin-filter ul {
diff -Naur drupal-5.0/modules/node/node.info drupal-5.23/modules/node/node.info
--- drupal-5.0/modules/node/node.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/node/node.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - required
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/node/node.module drupal-5.23/modules/node/node.module
--- drupal-5.0/modules/node/node.module	2007-01-14 03:12:29.000000000 +0100
+++ drupal-5.23/modules/node/node.module	2009-01-15 00:32:14.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: node.module,v 1.776 2007/01/14 02:12:29 unconed Exp $
+// $Id: node.module,v 1.776.2.33 2009/01/14 23:32:14 drumm Exp $
 
 /**
  * @file
@@ -35,7 +35,7 @@
       return '<p>'. t('To create a new content type, enter the human-readable name, the machine-readable name, and all other relevant fields that are on this page. Once created, users of your site will be able to create posts that are instances of this content type.') .'</p>';
   }
 
-  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions') {
+  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions' && arg(3) == NULL) {
     return '<p>'. t('The revisions let you track differences between multiple versions of a post.') .'</p>';
   }
 
@@ -103,7 +103,7 @@
   static $history;
 
   if (!isset($history[$nid])) {
-    $history[$nid] = db_fetch_object(db_query("SELECT timestamp FROM {history} WHERE uid = '$user->uid' AND nid = %d", $nid));
+    $history[$nid] = db_fetch_object(db_query("SELECT timestamp FROM {history} WHERE uid = %d AND nid = %d", $user->uid, $nid));
   }
 
   return (isset($history[$nid]->timestamp) ? $history[$nid]->timestamp : 0);
@@ -139,7 +139,20 @@
 }
 
 /**
- * Automatically generate a teaser for a node body in a given format.
+ * Automatically generate a teaser for a node body.
+ *
+ * If the end of the teaser is not indicated using the <!--break--> delimiter
+ * then we try to end it at a sensible place, such as the end of a paragraph,
+ * a line break, or the end of a sentence (in that order of preference).
+ *
+ * @param $body
+ *   The content for which a teaser will be generated.
+ * @param $format
+ *   The format of the content. If the content contains PHP code, we do not
+ *   split it up to prevent parse errors. If the line break filter is present
+ *   then we treat newlines embedded in $body as line breaks.
+ * @return
+ *   The generated teaser.
  */
 function node_teaser($body, $format = NULL) {
 
@@ -169,40 +182,67 @@
   }
 
   // If we have a short body, the entire body is the teaser.
-  if (strlen($body) < $size) {
+  if (strlen($body) <= $size) {
     return $body;
   }
 
+  // If the delimiter has not been specified, try to split at paragraph or
+  // sentence boundaries.
+
   // The teaser may not be longer than maximum length specified. Initial slice.
   $teaser = truncate_utf8($body, $size);
-  $position = 0;
-  // Cache the reverse of the teaser.
+
+  // Store the actual length of the UTF8 string -- which might not be the same
+  // as $size.
+  $max_rpos = strlen($teaser);
+
+  // How much to cut off the end of the teaser so that it doesn't end in the
+  // middle of a paragraph, sentence, or word.
+  // Initialize it to maximum in order to find the minimum.
+  $min_rpos = $max_rpos;
+
+  // Store the reverse of the teaser.  We use strpos on the reversed needle and
+  // haystack for speed and convenience.
   $reversed = strrev($teaser);
 
-  // In some cases, no delimiter has been specified. In this case, we try to
-  // split at paragraph boundaries.
-  $breakpoints = array('</p>' => 0, '<br />' => 6, '<br>' => 4, "\n" => 1);
-  // We use strpos on the reversed needle and haystack for speed.
-  foreach ($breakpoints as $point => $offset) {
-    $length = strpos($reversed, strrev($point));
-    if ($length !== FALSE) {
-      $position = - $length - $offset;
-      return ($position == 0) ? $teaser : substr($teaser, 0, $position);
-    }
+  // Build an array of arrays of break points grouped by preference.
+  $break_points = array();
+
+  // A paragraph near the end of sliced teaser is most preferable.
+  $break_points[] = array('</p>' => 0);
+
+  // If no complete paragraph then treat line breaks as paragraphs.
+  $line_breaks = array('<br />' => 6, '<br>' => 4);
+  // Newline only indicates a line break if line break converter
+  // filter is present.
+  if (isset($filters['filter/2'])) {
+    $line_breaks["\n"] = 1;
   }
+  $break_points[] = $line_breaks;
+
+  // If the first paragraph is too long, split at the end of a sentence.
+  $break_points[] = array('. ' => 1, '! ' => 1, '? ' => 1, 'ã€‚' => 0, 'ØŸ ' => 1);
+
+  // Iterate over the groups of break points until a break point is found.
+  foreach ($break_points as $points) {
+    // Look for each break point, starting at the end of the teaser.
+    foreach ($points as $point => $offset) {
+      // The teaser is already reversed, but the break point isn't.
+      $rpos = strpos($reversed, strrev($point));
+      if ($rpos !== FALSE) {
+        $min_rpos = min($rpos + $offset, $min_rpos);
+      }
+    }
 
-  // When even the first paragraph is too long, we try to split at the end of
-  // the last full sentence.
-  $breakpoints = array('. ' => 1, '! ' => 1, '? ' => 1, 'ã€‚' => 0, 'ØŸ ' => 1);
-  $min_length = strlen($reversed);
-  foreach ($breakpoints as $point => $offset) {
-    $length = strpos($reversed, strrev($point));
-    if ($length !== FALSE) {
-      $min_length = min($length, $min_length);
-      $position = 0 - $length - $offset;
+    // If a break point was found in this group, slice and return the teaser.
+    if ($min_rpos !== $max_rpos) {
+      // Don't slice with length 0.  Length must be <0 to slice from RHS.
+      return ($min_rpos === 0) ? $teaser : substr($teaser, 0, 0 - $min_rpos);
     }
   }
-  return ($position == 0) ? $teaser : substr($teaser, 0, $position);
+
+  // If a break point was not found, still return a teaser.
+  return $teaser;
 }
 
 /**
@@ -272,6 +312,9 @@
     if (!empty($info->is_new)) {
       node_type_save($info);
     }
+    if (!empty($info->disabled)) {
+      node_type_delete($info->type);
+    }
   }
 
   _node_types_build();
@@ -335,8 +378,10 @@
 }
 
 /**
- * Builds the list of available node types, by querying hook_node_info() in all
- * modules, and by looking for node types in the database.
+ * Builds and returns the list of available node types.
+ *
+ * The list of types is built by querying hook_node_info() in all modules, and
+ * by comparing this information with the node types in the {node_type} table.
  *
  */
 function _node_types_build() {
@@ -352,6 +397,12 @@
 
   $type_result = db_query(db_rewrite_sql('SELECT nt.type, nt.* FROM {node_type} nt ORDER BY nt.type ASC', 'nt', 'type'));
   while ($type_object = db_fetch_object($type_result)) {
+    // Check for node types from disabled modules and mark their types for removal.
+    // Types defined by the node module in the database (rather than by a separate
+    // module using hook_node_info) have a module value of 'node'.
+    if ($type_object->module != 'node' && empty($info_array[$type_object->type])) {
+       $type_object->disabled = TRUE;
+    }
     if (!isset($_node_types[$type_object->type]) || $type_object->modified) {
       $_node_types[$type_object->type] = $type_object;
       $_node_names[$type_object->type] = $type_object->name;
@@ -386,6 +437,12 @@
     $info['body_label'] = t('Body');
   }
 
+  if (!isset($info['help'])) {
+    $info['help'] = '';
+  }
+  if (!isset($info['min_word_count'])) {
+    $info['min_word_count'] = 0;
+  }
   if (!isset($info['custom'])) {
     $info['custom'] = FALSE;
   }
@@ -502,7 +559,7 @@
   else {
     // Turn the conditions into a query.
     foreach ($param as $key => $value) {
-      $cond[] = 'n.'. db_escape_string($key) ." = '%s'";
+      $cond[] = 'n.'. db_escape_table($key) ." = '%s'";
       $arguments[] = $value;
     }
     $cond = implode(' AND ', $cond);
@@ -554,7 +611,7 @@
     $node->is_new = TRUE;
 
     $node->nid = db_next_id('{node}_nid');
-    $node->vid = db_next_id('{node_revisions}_vid');;
+    $node->vid = db_next_id('{node_revisions}_vid');
   }
   else {
     // We need to ensure that all node fields are filled.
@@ -586,7 +643,7 @@
                      'title' => "'%s'", 'body' => "'%s'",
                      'teaser' => "'%s'", 'timestamp' => '%d',
                      'uid' => '%d', 'format' => '%d');
-  if (!empty($node->log) || $node->is_new) {
+  if (!empty($node->log) || $node->is_new || $node->revision) {
     // Only store the log message if there's something to store; this prevents
     // existing log messages from being unintentionally overwritten by a blank
     // message. A new revision will have an empty log message (or $node->log).
@@ -672,7 +729,7 @@
   $node = node_build_content($node, $teaser, $page);
 
   if ($links) {
-    $node->links = module_invoke_all('link', 'node', $node, !$page);
+    $node->links = module_invoke_all('link', 'node', $node, $teaser);
 
     foreach (module_implements('link_alter') AS $module) {
       $function = $module .'_link_alter';
@@ -903,12 +960,22 @@
         $join2 .= ' LEFT JOIN {node_counter} nc ON nc.nid = i.sid';
         $total += $weight;
       }
-      $select2 = (count($ranking) ? implode(' + ', $ranking) : 'i.relevance') .' AS score';
 
-      // Do search
+      // When all search factors are disabled (ie they have a weight of zero),
+      // the default score is based only on keyword relevance and there is no need to
+      // adjust the score of each item.
+      if ($total == 0) {
+        $select2 = 'i.relevance AS score';
+        $total = 1;
+      }
+      else {
+        $select2 = implode(' + ', $ranking) . ' AS score';
+      }
+
+      // Do search.
       $find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid '. $join1 .' INNER JOIN {users} u ON n.uid = u.uid', $conditions1 . (empty($where1) ? '' : ' AND '. $where1), $arguments1, $select2, $join2, $arguments2);
 
-      // Load results
+      // Load results.
       $results = array();
       foreach ($find as $item) {
         // Build the node body.
@@ -916,9 +983,9 @@
         $node = node_build_content($node, FALSE, FALSE);
         $node->body = drupal_render($node->content);
 
-        // Fetch comments for snippet
+        // Fetch comments for snippet.
         $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index');
-        // Fetch terms for snippet
+        // Fetch terms for snippet.
         $node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index');
 
         $extra = node_invoke_nodeapi($node, 'search result');
@@ -1142,11 +1209,10 @@
 
     foreach (node_get_types() as $type) {
       if (function_exists($type->module .'_form')) {
-        $name = check_plain($type->name);
         $type_url_str = str_replace('_', '-', $type->type);
         $items[] = array(
           'path' => 'node/add/'. $type_url_str,
-          'title' => drupal_ucfirst($name),
+          'title' => drupal_ucfirst($type->name),
           'access' => node_access('create', $type->type),
         );
       }
@@ -1195,11 +1261,28 @@
           'weight' => 1,
           'type' => MENU_CALLBACK);
         $revisions_access = ((user_access('view revisions') || user_access('administer nodes')) && node_access('view', $node) && db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', arg(1))) > 1);
-        $items[] = array('path' => 'node/'. arg(1) .'/revisions', 'title' => t('Revisions'),
+        $items[] = array(
+          'path' => 'node/'. arg(1) .'/revisions',
+          'title' => t('Revisions'),
           'callback' => 'node_revisions',
           'access' => $revisions_access,
           'weight' => 2,
-          'type' => MENU_LOCAL_TASK);
+          'type' => MENU_LOCAL_TASK,
+        );
+        if (!is_null(arg(3))) {
+          $items[] = array(
+            'path' => 'node/'. arg(1) .'/revisions/'. arg(3) .'/delete',
+            'callback' => 'node_revision_delete',
+            'callback arguments' => array(arg(1), arg(3)),
+            'type' => MENU_CALLBACK,
+          );
+          $items[] = array(
+            'path' => 'node/'. arg(1) .'/revisions/'. arg(3) .'/revert',
+            'callback' => 'node_revision_revert',
+            'callback arguments' => array(arg(1), arg(3)),
+            'type' => MENU_CALLBACK,
+          );
+        }
       }
     }
 
@@ -1213,7 +1296,6 @@
         $type = node_get_types('type', $type_name);
 
         if (!empty($type)) {
-          $type->name = check_plain($type->name);
           $type_url_str = str_replace('_', '-', $type->type);
 
           $items[] = array(
@@ -1282,42 +1364,48 @@
  * Callback function for admin mass publishing nodes.
  */
 function node_operations_publish($nodes) {
-  db_query('UPDATE {node} SET status = 1 WHERE nid IN(%s)', implode(',', $nodes));
+  $placeholders = implode(',', array_fill(0, count($nodes), '%d'));
+  db_query('UPDATE {node} SET status = 1 WHERE nid IN('. $placeholders .')', $nodes);
 }
 
 /**
  * Callback function for admin mass unpublishing nodes.
  */
 function node_operations_unpublish($nodes) {
-  db_query('UPDATE {node} SET status = 0 WHERE nid IN(%s)', implode(',', $nodes));
+  $placeholders = implode(',', array_fill(0, count($nodes), '%d'));
+  db_query('UPDATE {node} SET status = 0 WHERE nid IN('. $placeholders .')', $nodes);
 }
 
 /**
  * Callback function for admin mass promoting nodes.
  */
 function node_operations_promote($nodes) {
-  db_query('UPDATE {node} SET status = 1, promote = 1 WHERE nid IN(%s)', implode(',', $nodes));
+  $placeholders = implode(',', array_fill(0, count($nodes), '%d'));
+  db_query('UPDATE {node} SET status = 1, promote = 1 WHERE nid IN('. $placeholders .')', $nodes);
 }
 
 /**
  * Callback function for admin mass demoting nodes.
  */
 function node_operations_demote($nodes) {
-  db_query('UPDATE {node} SET promote = 0 WHERE nid IN(%s)', implode(',', $nodes));
+  $placeholders = implode(',', array_fill(0, count($nodes), '%d'));
+  db_query('UPDATE {node} SET promote = 0 WHERE nid IN('. $placeholders .')', $nodes);
 }
 
 /**
  * Callback function for admin mass editing nodes to be sticky.
  */
 function node_operations_sticky($nodes) {
-  db_query('UPDATE {node} SET status = 1, sticky = 1 WHERE nid IN(%s)', implode(',', $nodes));
+  $placeholders = implode(',', array_fill(0, count($nodes), '%d'));
+  db_query('UPDATE {node} SET status = 1, sticky = 1 WHERE nid IN('. $placeholders .')', $nodes);
 }
 
 /**
  * Callback function for admin mass editing nodes to remove stickiness.
  */
 function node_operations_unsticky($nodes) {
-  db_query('UPDATE {node} SET sticky = 0 WHERE nid IN(%s)', implode(',', $nodes));
+  $placeholders = implode(',', array_fill(0, count($nodes), '%d'));
+  db_query('UPDATE {node} SET sticky = 0 WHERE nid IN('. $placeholders .')', $nodes);
 }
 
 /**
@@ -1390,15 +1478,15 @@
       $value = module_invoke('taxonomy', 'get_term', $value);
       $value = $value->name;
     }
-    else if ($type == 'type') {
-      // Remove the type option if it is already being filtered on.
-      unset($filters['type']);
-    }
     else {
       $value = $filters[$type]['options'][$value];
     }
     $string = ($i++ ? '<em>and</em> where <strong>%a</strong> is <strong>%b</strong>' : '<strong>%a</strong> is <strong>%b</strong>');
     $form['filters']['current'][] = array('#value' => t($string, array('%a' => $filters[$type]['title'] , '%b' => $value)));
+    if ($type == 'type') {
+      // Remove the type option if it is already being filtered on.
+      unset($filters['type']);
+    }
   }
 
   foreach ($filters as $key => $filter) {
@@ -1532,7 +1620,6 @@
 }
 
 function node_admin_nodes() {
-  global $form_values;
   $filter = node_build_filter_query();
 
   $result = pager_query('SELECT n.*, u.name, u.uid FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] .' ORDER BY n.changed DESC', 50, 0, NULL, $filter['args']);
@@ -1553,7 +1640,7 @@
   while ($node = db_fetch_object($result)) {
     $nodes[$node->nid] = '';
     $form['title'][$node->nid] = array('#value' => l($node->title, 'node/'. $node->nid) .' '. theme('mark', node_mark($node->nid, $node->changed)));
-    $form['name'][$node->nid] =  array('#value' => node_get_types('name', $node));
+    $form['name'][$node->nid] =  array('#value' => check_plain(node_get_types('name', $node)));
     $form['username'][$node->nid] = array('#value' => theme('username', $node));
     $form['status'][$node->nid] =  array('#value' =>  ($node->status ? t('published') : t('not published')));
     $form['operations'][$node->nid] = array('#value' => l(t('edit'), 'node/'. $node->nid .'/edit', array(), $destination));
@@ -1666,9 +1753,8 @@
     }
     $rows[] = array_merge($row, $operations);
   }
-  $output .= theme('table', $header, $rows);
 
-  return $output;
+  return theme('table', $header, $rows);
 }
 
 /**
@@ -1681,16 +1767,7 @@
   $node = node_load($nid, $revision);
   if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
     if ($node->vid) {
-      $node->revision = 1;
-      $node->log = t('Copy of the revision from %date.', array('%date' => format_date($node->revision_timestamp)));
-      if (module_exists('taxonomy')) {
-        $node->taxonomy = array_keys($node->taxonomy);
-      }
-
-      node_save($node);
-
-      drupal_set_message(t('%title has been reverted back to the revision from %revision-date', array('%revision-date' => format_date($node->revision_timestamp), '%title' => $node->title)));
-      watchdog('content', t('@type: reverted %title revision %revision.', array('@type' => t($node->type), '%title' => $node->title, '%revision' => $revision)));
+      return drupal_get_form('node_revision_revert_confirm', $node);
     }
     else {
       drupal_set_message(t('You tried to revert to an invalid revision.'), 'error');
@@ -1701,6 +1778,31 @@
 }
 
 /**
+ * Ask for confirmation of the reversion to prevent against CSRF attacks.
+ */
+function node_revision_revert_confirm($node) {
+  $form['node'] = array('#type' => 'value', '#value' => $node);
+  return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' =>  format_date($node->revision_timestamp))), 'node/'. $node->nid .'/revisions', '', t('Revert'), t('Cancel'));
+}
+
+function node_revision_revert_confirm_submit($form_id, $form_values) {
+  $node = $form_values['node'];
+
+  $node->revision = 1;
+  $node->log = t('Copy of the revision from %date.', array('%date' => format_date($node->revision_timestamp)));
+  if (module_exists('taxonomy')) {
+    $node->taxonomy = array_keys($node->taxonomy);
+  }
+
+  node_save($node);
+
+  drupal_set_message(t('%title has been reverted back to the revision from %revision-date', array('%revision-date' => format_date($node->revision_timestamp), '%title' => $node->title)));
+  watchdog('content', t('@type: reverted %title revision %revision.', array('@type' => t($node->type), '%title' => $node->title, '%revision' => $node->vid)));
+
+  return 'node/'. $node->nid .'/revisions';
+}
+
+/**
  * Delete the revision with specified revision number. A "delete revision" nodeapi event is invoked when a
  * revision is deleted.
  */
@@ -1710,22 +1812,22 @@
     if (node_access('delete', $node)) {
       // Don't delete the current revision
       if ($revision != $node->vid) {
-        $node = node_load($nid, $revision);
-
-        db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $nid, $revision);
-        node_invoke_nodeapi($node, 'delete revision');
-        drupal_set_message(t('Deleted %title revision %revision.', array('%title' => $node->title, '%revision' => $revision)));
-        watchdog('content', t('@type: deleted %title revision %revision.', array('@type' => t($node->type), '%title' => $node->title, '%revision' => $revision)));
+        if ($node = node_load($nid, $revision)) {
+          return drupal_get_form('node_revision_delete_confirm', $node);
+        }
+        else {
+          drupal_set_message(t('Deletion failed. You tried to delete a non-existing revision.'));
+        }
       }
-
       else {
         drupal_set_message(t('Deletion failed. You tried to delete the current revision.'));
       }
+
       if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $nid)) > 1) {
-        drupal_goto("node/$nid/revisions");
+        drupal_goto('node/'. $nid .'/revisions');
       }
       else {
-        drupal_goto("node/$nid");
+        drupal_goto('node/'. $nid);
       }
     }
   }
@@ -1734,6 +1836,29 @@
 }
 
 /**
+ * Ask confirmation for revision deletion to prevent against CSRF attacks.
+ */
+function node_revision_delete_confirm($node) {
+  $form['node'] = array('#type' => 'value', '#value' => $node);
+  return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' =>  format_date($node->revision_timestamp))), 'node/'. $node->nid .'/revisions', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
+}
+
+function node_revision_delete_confirm_submit($form_id, $form_values) {
+  $node = $form_values['node'];
+  db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $node->nid, $node->vid);
+  node_invoke_nodeapi($node, 'delete revision');
+  drupal_set_message(t('Deleted %title revision %revision.', array('%title' => $node->title, '%revision' => $node->vid)));
+  watchdog('content', t('@type: deleted %title revision %revision.', array('@type' => t($node->type), '%title' => $node->title, '%revision' => $node->vid)));
+
+  if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node->nid)) > 1) {
+    return 'node/'. $node->nid .'/revisions';
+  }
+  else {
+    return 'node/'. $node->nid;
+  }
+}
+
+/**
  * Return a list of all the existing revision numbers.
  */
 function node_revision_list($node) {
@@ -1807,7 +1932,7 @@
 
     // Allow modules to add additional item fields and/or modify $item
     $extra = node_invoke_nodeapi($item, 'rss item');
-    $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' =>  date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid .' at '. $base_url, 'attributes' => array('isPermaLink' => 'false'))));
+    $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => gmdate('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid .' at '. $base_url, 'attributes' => array('isPermaLink' => 'false'))));
     foreach ($extra as $element) {
       if ($element['namespace']) {
         $namespaces = array_merge($namespaces, $element['namespace']);
@@ -1835,7 +1960,7 @@
 
   $channel_defaults = array(
     'version'     => '2.0',
-    'title'       => variable_get('site_name', 'Drupal') .' - '. variable_get('site_slogan', ''),
+    'title'       => variable_get('site_name', 'Drupal') . (variable_get('site_slogan', '') ? ' - '. variable_get('site_slogan', '') : ''),
     'link'        => $base_url,
     'description' => variable_get('site_mission', ''),
     'language'    => $locale
@@ -1866,8 +1991,7 @@
     $node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
   }
 
-  $access = user_access('administer nodes');
-  if ($access) {
+  if (user_access('administer nodes')) {
     // Populate the "authored by" field.
     if ($account = user_load(array('name' => $node->name))) {
       $node->uid = $account->uid;
@@ -1875,27 +1999,9 @@
     else {
       $node->uid = 0;
     }
-
-    $node->created = $node->date ? strtotime($node->date) : NULL;
   }
 
-  // Process the workflow options and provide defaults. If the user
-  // can not administer nodes, ignore the form and either use the
-  // saved values if the node exists, or force the defaults.
-  if (!$access && $node->nid) {
-    $saved_node = node_load($node->nid);
-  }
-  else {
-    $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
-  }
-  foreach (array('status', 'promote', 'sticky', 'revision') as $key) {
-    if (!$access && $node->nid) {
-      $node->$key = $saved_node->$key;
-    }
-    else if (!isset($node->$key) || !$access) {
-      $node->$key = in_array($key, $node_options);
-    }
-  }
+  $node->created = !empty($node->date) ? strtotime($node->date) : time();
 
   // Do node-type-specific validation checks.
   node_invoke($node, 'submit');
@@ -1949,16 +2055,14 @@
 }
 
 function node_object_prepare(&$node) {
-  if (user_access('administer nodes')) {
-    // Set up default values, if required.
-    if (!isset($node->created)) {
-      $node->created = time();
-    }
-
-    if (!isset($node->date)) {
-      $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
-    }
+  // Set up default values, if required.
+  if (!isset($node->created)) {
+    $node->created = time();
   }
+  if (!isset($node->date)) {
+    $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
+  }
+
   node_invoke($node, 'prepare');
   node_invoke_nodeapi($node, 'prepare');
 }
@@ -1987,7 +2091,9 @@
   $form['changed'] = array('#type' => 'hidden', '#default_value' => $node->changed);
 
   // Get the node-specific bits.
-  $form = array_merge_recursive($form, node_invoke($node, 'form', $form_values));
+  if ($extra = node_invoke($node, 'form', $form_values)) {
+    $form = array_merge_recursive($form, $extra);
+  }
   if (!isset($form['title']['#weight'])) {
     $form['title']['#weight'] = -5;
   }
@@ -1995,16 +2101,15 @@
   $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
   // If this is a new node, fill in the default values.
   if (!isset($node->nid)) {
-    foreach (array('status', 'promote', 'sticky', 'revision') as $key) {
+    foreach (array('status', 'promote', 'sticky') as $key) {
       $node->$key = in_array($key, $node_options);
     }
     global $user;
     $node->uid = $user->uid;
   }
-  else {
-    // Nodes being edited should always be preset with the default revision setting.
-    $node->revision = in_array('revision', $node_options);
-  }
+  // Always use the default revision setting.
+  $node->revision = in_array('revision', $node_options);
+
   $form['#node'] = $node;
 
   // Add a log field if the "Create new revision" option is checked, or if the
@@ -2029,9 +2134,9 @@
     '#weight' => 20,
   );
   $form['author']['name'] = array('#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#default_value' => $node->name ? $node->name : '', '#weight' => -1, '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))));
-  $form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, '#description' => t('Format: %time. Leave blank to use the time of form submission.', array('%time' => $node->date)));
+  $form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, '#description' => t('Format: %time. Leave blank to use the time of form submission.', array('%time' => !empty($node->date) ? $node->date : format_date($node->created, 'custom', 'Y-m-d H:i:s O'))));
 
-  if (isset($node->nid)) {
+  if (isset($node->date)) {
     $form['author']['date']['#default_value'] = $node->date;
   }
 
@@ -2060,6 +2165,14 @@
     $form['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 50);
   }
   $form['#after_build'] = array('node_form_add_preview');
+  // Ensure that node_validate() will always get called.
+  $form['#validate']['node_form_validate'] = array();
+  // Also, if the module defines its own _validate() routine based on the
+  // form_id, include that in the #validate array, as well.
+  $node_validate = $node->type .'_node_form_validate';
+  if (function_exists($node_validate)) {
+    $form['#validate'][$node_validate] = array();
+  }
   $form['#base'] = 'node_form';
   return $form;
 }
@@ -2069,6 +2182,10 @@
 
   $op = isset($form_values['op']) ? $form_values['op'] : '';
   if ($op == t('Preview')) {
+    // Invoke full validation for the form, to protect against cross site
+    // request forgeries (CSRF) and setting arbitrary values for fields such as
+    // the input format. Preview the node only when form validation does not
+    // set any errors.
     drupal_validate_form($form['form_id']['#value'], $form);
     if (!form_get_errors()) {
       // Because the node preview may display a form, we must render it
@@ -2152,7 +2269,7 @@
         $title = t('Add a new @s.', array('@s' => $type->name));
         $out = '<dt>'. l(drupal_ucfirst($type->name), "node/add/$type_url_str", array('title' => $title)) .'</dt>';
         $out .= '<dd>'. filter_xss_admin($type->description) .'</dd>';
-        $item[$type->type] = $out;
+        $item[$type->name] = $out;
       }
     }
 
@@ -2191,10 +2308,6 @@
       $node->picture = $user->picture;
     }
 
-    // Set the timestamps when needed:
-    if ($node->date) {
-      $node->created = strtotime($node->date);
-    }
     $node->changed = time();
 
     // Extract a teaser, if it hasn't been set (e.g. by a module-provided
@@ -2281,7 +2394,7 @@
 
  return confirm_form($form,
    t('Are you sure you want to delete %title?', array('%title' => $node->title)),
-   $_GET['destination'] ? $_GET['destination'] : 'node/'. $node->nid,
+   isset($_GET['destination']) ? $_GET['destination'] : 'node/'. $node->nid,
    t('This action cannot be undone.'),
    t('Delete'), t('Cancel'));
 }
@@ -2351,12 +2464,6 @@
           }
         }
         break;
-      case 'revert':
-        node_revision_revert(arg(1), arg(3));
-        break;
-      case 'delete':
-        node_revision_delete(arg(1), arg(3));
-        break;
     }
   }
   drupal_not_found();
@@ -2365,7 +2472,11 @@
 /**
  * Menu callback; Generate a listing of promoted nodes.
  */
-function node_page_default() {
+function node_page_default($arg = NULL) {
+  // Prevent fallback to this page for node/*.
+  if (isset($arg)) {
+    return MENU_NOT_FOUND;
+  }
 
   $result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));
 
@@ -2390,8 +2501,8 @@
       $default_message .= '<li>'. t('<strong>Create your administrator account</strong> To begin, <a href="@register">create the first account</a>. This account will have full administration rights and will allow you to configure your website.', array('@register' => url('user/register'))) .'</li>';
     }
     $default_message .= '<li>'. t('<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where you can <a href="@config">customize and configure</a> all aspects of your website.', array('@admin' => url('admin'), '@config' => url('admin/settings'))) .'</li>';
-    $default_message .= '<li>'. t('<strong>Enable additional functionality</strong> Next, visit the <a href="@modules">module list</a> and enable features which suit your specific needs. You can find additional modules in the <a href="@download_modules">Drupal modules download section</a>.', array('@modules' => url('admin/build/modules'), '@download_modules' => 'http://drupal.org/project/modules')) .'</li>';
-    $default_message .= '<li>'. t('<strong>Customize your website design</strong> To change the "look and feel" of your website, visit the <a href="@themes">themes section</a>. You may choose from one of the included themes or download additional themes from the <a href="@download_themes">Drupal themes download section</a>.', array('@themes' => url('admin/build/themes'), '@download_themes' => 'http://drupal.org/project/themes')) .'</li>';
+    $default_message .= '<li>'. t('<strong>Enable additional functionality</strong> Next, visit the <a href="@modules">module list</a> and enable features which suit your specific needs. You can find additional modules in the <a href="@download_modules">Drupal modules download section</a>.', array('@modules' => url('admin/build/modules'), '@download_modules' => 'http://drupal.org/project/Modules')) .'</li>';
+    $default_message .= '<li>'. t('<strong>Customize your website design</strong> To change the "look and feel" of your website, visit the <a href="@themes">themes section</a>. You may choose from one of the included themes or download additional themes from the <a href="@download_themes">Drupal themes download section</a>.', array('@themes' => url('admin/build/themes'), '@download_themes' => 'http://drupal.org/project/Themes')) .'</li>';
     $default_message .= '<li>'. t('<strong>Start posting content</strong> Finally, you can <a href="@content">create content</a> for your website. This message will disappear once you have promoted a post to the front page.', array('@content' => url('node/add'))) .'</li>';
     $default_message .= '</ol>';
     $default_message .= '<p>'. t('For more information, please refer to the <a href="@help">help section</a>, or the <a href="@handbook">online Drupal handbooks</a>. You may also post at the <a href="@forum">Drupal forum</a>, or view the wide range of <a href="@support">other support options</a> available.', array('@help' => url('admin/help'), '@handbook' => 'http://drupal.org/handbooks', '@forum' => 'http://drupal.org/forum', '@support' => 'http://drupal.org/support')) .'</p>';
@@ -2467,6 +2578,9 @@
     $node = node_build_content($node, FALSE, FALSE);
     $node->body = drupal_render($node->content);
 
+    // Allow modules to modify the fully-built node.
+    node_invoke_nodeapi($node, 'alter');
+
     $text = '<h1>'. check_plain($node->title) .'</h1>'. $node->body;
 
     // Fetch extra data normally not visible
@@ -2531,7 +2645,7 @@
     }
 
     // Node types:
-    $types = node_get_types('names');
+    $types = array_map('check_plain', node_get_types('names'));
     $form['advanced']['type'] = array(
       '#type' => 'checkboxes',
       '#title' => t('Only of the type(s)'),
@@ -2542,7 +2656,7 @@
     $form['advanced']['submit'] = array(
       '#type' => 'submit',
       '#value' => t('Advanced search'),
-      '#prefix' => '<div class="action clear-block">',
+      '#prefix' => '<div class="action">',
       '#suffix' => '</div>',
     );
 
@@ -2639,6 +2753,11 @@
 function node_access($op, $node = NULL) {
   global $user;
 
+  if (!$node || !in_array($op, array('view', 'update', 'delete', 'create'), TRUE)) {
+    // If there was no node to check against, or the $op was not one of the
+    // supported ones, we return access denied.
+    return FALSE;
+  }
   // Convert the node to an object if necessary:
   if ($op != 'create') {
     $node = (object)$node;
@@ -2903,7 +3022,12 @@
     }
     $result = db_query("SELECT nid FROM {node}");
     while ($node = db_fetch_object($result)) {
-      node_access_acquire_grants(node_load($node->nid));
+      $loaded_node = node_load($node->nid, NULL, TRUE);
+      // To preserve database integrity, only aquire grants if the node
+      // loads successfully.
+      if (!empty($loaded_node)) {
+        node_access_acquire_grants($loaded_node);
+      }
     }
   }
   else {
diff -Naur drupal-5.0/modules/path/path.info drupal-5.23/modules/path/path.info
--- drupal-5.0/modules/path/path.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/path/path.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/path/path.module drupal-5.23/modules/path/path.module
--- drupal-5.0/modules/path/path.module	2007-01-09 09:34:03.000000000 +0100
+++ drupal-5.23/modules/path/path.module	2009-01-14 06:59:09.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: path.module,v 1.105 2007/01/09 08:34:03 dries Exp $
+// $Id: path.module,v 1.105.2.3 2009/01/14 05:59:09 drumm Exp $
 
 /**
  * @file
@@ -97,7 +97,7 @@
     $form['pid'] = array('#type' => 'value', '#value' => $pid);
     $output = confirm_form($form,
   t('Are you sure you want to delete path alias %title?', array('%title' => $path['dst'])),
-   $_GET['destination'] ? $_GET['destination'] : 'admin/build/path', t('This action cannot be undone.'),
+   isset($_GET['destination']) ? $_GET['destination'] : 'admin/build/path', t('This action cannot be undone.'),
   t('Delete'), t('Cancel') );
   }
 
@@ -179,7 +179,7 @@
     '#type' => 'textfield',
     '#title' => t('Existing system path'),
     '#default_value' => $edit['src'],
-    '#maxlength' => 64,
+    '#maxlength' => 128,
     '#size' => 45,
     '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1+2.'),
     '#field_prefix' => url(NULL, NULL, NULL, TRUE) . (variable_get('clean_url', 0) ? '' : '?q=')
@@ -187,7 +187,7 @@
   $form['dst'] = array(
     '#type' => 'textfield',
     '#default_value' => $edit['dst'],
-    '#maxlength' => 64,
+    '#maxlength' => 128,
     '#size' => 45,
     '#description' => t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
     '#field_prefix' => url(NULL, NULL, NULL, TRUE) . (variable_get('clean_url', 0) ? '' : '?q=')
@@ -211,7 +211,7 @@
  * than through the administrative interface.
  */
 function path_nodeapi(&$node, $op, $arg) {
-  if (user_access('create url aliases') || user_access('administer url aliases')) {
+  if (user_access('create url aliases') || user_access('administer url aliases') || ($op == 'load')) {
     switch ($op) {
       case 'validate':
         $node->path = trim($node->path);
@@ -269,7 +269,7 @@
     $form['path']['path'] = array(
       '#type' => 'textfield',
       '#default_value' => $path,
-      '#maxlength' => 250,
+      '#maxlength' => 128,
       '#collapsible' => TRUE,
       '#collapsed' => TRUE,
       '#description' => t('Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
diff -Naur drupal-5.0/modules/ping/ping.info drupal-5.23/modules/ping/ping.info
--- drupal-5.0/modules/ping/ping.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/ping/ping.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/poll/poll.info drupal-5.23/modules/poll/poll.info
--- drupal-5.0/modules/poll/poll.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/poll/poll.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/poll/poll.module drupal-5.23/modules/poll/poll.module
--- drupal-5.0/modules/poll/poll.module	2006-12-25 10:48:42.000000000 +0100
+++ drupal-5.23/modules/poll/poll.module	2008-10-05 02:51:40.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: poll.module,v 1.222 2006/12/25 09:48:42 drumm Exp $
+// $Id: poll.module,v 1.222.2.5 2008/10/05 00:51:40 drumm Exp $
 
 /**
  * @file
@@ -217,6 +217,7 @@
 
   db_query("INSERT INTO {poll} (nid, runtime, active) VALUES (%d, %d, %d)", $node->nid, $node->runtime, $node->active);
 
+  $i = 0;
   foreach ($node->choice as $choice) {
     if ($choice['chtext'] != '') {
       db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $choice['chtext'], $choice['chvotes'], $i++);
@@ -283,15 +284,15 @@
 function poll_load($node) {
   global $user;
 
-  // Load the appropriate choices into the $node object
   $poll = db_fetch_object(db_query("SELECT runtime, active FROM {poll} WHERE nid = %d", $node->nid));
 
+  // Load the appropriate choices into the $poll object.
   $result = db_query("SELECT chtext, chvotes, chorder FROM {poll_choices} WHERE nid = %d ORDER BY chorder", $node->nid);
   while ($choice = db_fetch_array($result)) {
     $poll->choice[$choice['chorder']] = $choice;
   }
 
-  // Determine whether or not this user is allowed to vote
+  // Determine whether or not this user is allowed to vote.
   $poll->allowvotes = FALSE;
   if (user_access('vote on polls') && $poll->active) {
     if ($user->uid) {
@@ -327,10 +328,11 @@
 }
 
 function poll_page() {
-  // List all polls
-  $sql = "SELECT n.nid, n.title, p.active, n.created, SUM(c.chvotes) AS votes FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid INNER JOIN {poll_choices} c ON n.nid = c.nid WHERE n.status = 1 GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC";
-  $sql = db_rewrite_sql($sql);
-  $result = pager_query($sql, 15);
+  // List all polls.
+  $sql = db_rewrite_sql("SELECT n.nid, n.title, p.active, n.created, SUM(c.chvotes) AS votes FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid INNER JOIN {poll_choices} c ON n.nid = c.nid WHERE n.status = 1 GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC");
+  // Count all polls for the pager.
+  $count_sql = db_rewrite_sql('SELECT COUNT(*) FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid WHERE n.status = 1');
+  $result = pager_query($sql, 15, 0, $count_sql);
   $output = '<ul>';
   while ($node = db_fetch_object($result)) {
     $output .= '<li>'. l($node->title, "node/$node->nid") .' - '. format_plural($node->votes, '1 vote', '@count votes') .' - '. ($node->active ? t('open') : t('closed')) .'</li>';
@@ -354,7 +356,9 @@
   $teaser = NULL;
   if (is_array($node->choice)) {
     foreach ($node->choice as $k => $choice) {
-      $teaser .= '* '. $choice['chtext'] .'\n';
+      if ($choice['chtext'] != '') {
+        $teaser .= '* '. check_plain($choice['chtext']) ."\n";
+      }
     }
   }
   return $teaser;
@@ -625,18 +629,32 @@
  * Implementation of hook_update().
  */
 function poll_update($node) {
+  // Update poll settings.
   db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid);
 
+  // Clean poll choices.
   db_query('DELETE FROM {poll_choices} WHERE nid = %d', $node->nid);
-  db_query('DELETE FROM {poll_votes} WHERE nid = %d', $node->nid);
 
-  $i = 0;
-  foreach ($node->choice as $choice) {
-    $chvotes = (int)$choice['chvotes'];
+  // Poll choices come in the same order with the same numbers as they are in
+  // the database, but some might have an empty title, which signifies that
+  // they should be removed. We remove all votes to the removed options, so
+  // people who voted on them can vote again.
+  $new_chorder = 0;
+  foreach ($node->choice as $old_chorder => $choice) {
+    $chvotes = isset($choice['chvotes']) ? (int)$choice['chvotes'] : 0;
     $chtext = $choice['chtext'];
 
-    if ($chtext != '') {
-      db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $chtext, $chvotes, $i++);
+    if (!empty($chtext)) {
+      db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $chtext, $chvotes, $new_chorder);
+      if ($new_chorder != $old_chorder) {
+        // We can only remove items in the middle, not add, so
+        // new_chorder is always <= old_chorder, making this safe.
+        db_query("UPDATE {poll_votes} SET chorder = %d WHERE nid = %d AND chorder = %d", $new_chorder, $node->nid, $old_chorder);
+      }
+      $new_chorder++;
+    }
+    else {
+      db_query("DELETE FROM {poll_votes} WHERE nid = %d AND chorder = %d", $node->nid, $old_chorder);
     }
   }
 }
diff -Naur drupal-5.0/modules/profile/profile.info drupal-5.23/modules/profile/profile.info
--- drupal-5.0/modules/profile/profile.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/profile/profile.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/profile/profile.module drupal-5.23/modules/profile/profile.module
--- drupal-5.0/modules/profile/profile.module	2007-01-11 04:31:18.000000000 +0100
+++ drupal-5.23/modules/profile/profile.module	2009-01-14 06:38:52.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: profile.module,v 1.189 2007/01/11 03:31:18 unconed Exp $
+// $Id: profile.module,v 1.189.2.11 2009/01/14 05:38:52 drumm Exp $
 
 /**
  * @file
@@ -47,7 +47,7 @@
       $output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="@profile">Profile page</a>.', array('@profile' => 'http://drupal.org/handbook/modules/profile/')) .'</p>';
       return $output;
     case 'admin/user/profile':
-      return '<p>'. t('Here you can define custom fields that users can fill in in their user profile (such as <em>country</em>, <em>real name</em>, <em>age</em>, ...).') .'</p>';
+      return '<p>'. t('Here you can define custom fields that users can fill in as part of their user profile (such as <em>country</em>, <em>real name</em>, <em>age</em>, ...).') .'</p>';
   }
 }
 
@@ -111,7 +111,7 @@
     $fields = array();
     $result = db_query('SELECT name, title, weight, visibility FROM {profile_fields} WHERE visibility IN (%d, %d) ORDER BY weight', PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS);
     while ($record = db_fetch_object($result)) {
-      $fields[$record->name] = $record->title;
+      $fields[$record->name] = check_plain($record->title);
     }
     $fields['user_profile'] = t('Link to full user profile');
     $form['profile_block_author_fields'] = array('#type' => 'checkboxes',
@@ -149,7 +149,7 @@
         }
 
         if (isset($use_fields['user_profile']) && $use_fields['user_profile']) {
-          $output .= '<div>' . l(t('View full user profile'), 'user/' . $account->uid) . '</div>';
+          $output .= '<div>'. l(t('View full user profile'), 'user/'. $account->uid) .'</div>';
         }
       }
 
@@ -172,8 +172,9 @@
     case 'register':
       return profile_form_profile($edit, $user, $category, TRUE);
     case 'update':
-    case 'insert':
       return profile_save_profile($edit, $user, $category);
+    case 'insert':
+      return profile_save_profile($edit, $user, $category, TRUE);
     case 'view':
       return profile_view_profile($user);
     case 'form':
@@ -335,6 +336,14 @@
   if (db_result(db_query("SELECT fid FROM {profile_fields} WHERE name = '%s'". $query_suffix, $args2))) {
     form_set_error('name', t('The specified name is already in use.'));
   }
+  if ($form_values['visibility'] == PROFILE_HIDDEN) {
+    if ($form_values['required']) {
+      form_set_error('required', t('A hidden field cannot be required.'));
+    }
+    if ($form_values['register']) {
+      form_set_error('register', t('A hidden field cannot be set to visible on the user registration form.'));
+    }
+  }
 }
 
 /**
@@ -371,7 +380,7 @@
 
   return confirm_form($form,
     t('Are you sure you want to delete the field %field?', array('%field' => $field->title)), 'admin/user/profile',
-    t('This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to <a href="@edit-field">edit this field</a> and change it to a hidden profile field so that it may only be accessed by administrators.', array('@edit-field' => url('admin/user/profile/edit/' . $fid))),
+    t('This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to <a href="@edit-field">edit this field</a> and change it to a hidden profile field so that it may only be accessed by administrators.', array('@edit-field' => url('admin/user/profile/edit/'. $fid))),
     t('Delete'), t('Cancel'));
 }
 
@@ -395,10 +404,10 @@
  */
 function profile_admin_overview() {
 
-  $result = db_query('SELECT * FROM {profile_fields} ORDER BY category, weight');
+  $result = db_query('SELECT title, name, type, category, fid FROM {profile_fields} ORDER BY category, weight');
   $rows = array();
   while ($field = db_fetch_object($result)) {
-    $rows[] = array(check_plain($field->title), $field->name, _profile_field_types($field->type), $field->category, l(t('edit'), "admin/user/profile/edit/$field->fid"), l(t('delete'), "admin/user/profile/delete/$field->fid"));
+    $rows[] = array(check_plain($field->title), check_plain($field->name), _profile_field_types($field->type), check_plain($field->category), l(t('edit'), "admin/user/profile/edit/$field->fid"), l(t('delete'), "admin/user/profile/delete/$field->fid"));
   }
   if (count($rows) == 0) {
     $rows[] = array(array('data' => t('No fields defined.'), 'colspan' => '6'));
@@ -422,7 +431,7 @@
  */
 function profile_browse() {
   $name = arg(1);
-  list(,,$value) = explode('/', $_GET['q'], 3);
+  list(, , $value) = explode('/', $_GET['q'], 3);
 
   $field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page, visibility FROM {profile_fields} WHERE name = '%s'", $name));
 
@@ -432,8 +441,8 @@
       drupal_not_found();
       return;
     }
-    // Do not allow browsing of private fields by non-admins.
-    if (!user_access('administer users') && $field->visibility == PROFILE_PRIVATE) {
+    // Do not allow browsing of private and hidden fields by non-admins.
+    if (!user_access('administer users') && ($field->visibility == PROFILE_PRIVATE || $field->visibility == PROFILE_HIDDEN)) {
        drupal_access_denied();
        return;
     }
@@ -510,7 +519,7 @@
     $output .= '</div>';
     $output .= theme('pager', NULL, 20);
 
-    drupal_set_title(t('user list'));
+    drupal_set_title(t('User list'));
     return $output;
   }
 }
@@ -524,8 +533,8 @@
   }
 }
 
-function profile_save_profile(&$edit, &$user, $category) {
-  $result = _profile_get_fields($category);
+function profile_save_profile(&$edit, &$user, $category, $register = FALSE) {
+  $result = _profile_get_fields($category, $register);
   while ($field = db_fetch_object($result)) {
     if (_profile_field_serialize($field->type)) {
        $edit[$field->name] = serialize($edit[$field->name]);
@@ -623,11 +632,11 @@
 
 function profile_form_profile($edit, $user, $category, $register = FALSE) {
   $result = _profile_get_fields($category, $register);
-  $w = 0;
+  $w = 1;
   while ($field = db_fetch_object($result)) {
     $category = $field->category;
     if (!isset($fields[$category])) {
-      $fields[$category] = array('#type' => 'fieldset', '#title' => $category, '#weight' => $w++);
+      $fields[$category] = array('#type' => 'fieldset', '#title' => check_plain($category), '#weight' => $w++);
     }
     switch ($field->type) {
       case 'textfield':
@@ -669,7 +678,7 @@
         break;
       case 'selection':
         $options = $field->required ? array() : array('--');
-        $lines = split("[,\n\r]", $field->options);
+        $lines = split("[\n\r]", $field->options);
         foreach ($lines as $line) {
           if ($line = trim($line)) {
             $options[$line] = $line;
@@ -741,7 +750,15 @@
 }
 
 function profile_categories() {
-  $result = db_query("SELECT DISTINCT(category) FROM {profile_fields}");
+  // Hide hidden profile fields from users that don't have permission to administer users.
+  // For these users, categories with only hidden profile fields will not be returned.
+  if (user_access('administer users')) {
+    $result = db_query("SELECT DISTINCT(category) FROM {profile_fields}");
+  }
+  else {
+    $result = db_query("SELECT DISTINCT(category) FROM {profile_fields} WHERE visibility <> %d", PROFILE_HIDDEN);
+  }
+
   while ($category = db_fetch_object($result)) {
     $data[] = array('name' => $category->category, 'title' => $category->category, 'weight' => 3);
   }
@@ -758,7 +775,7 @@
         $output .= "<p>$field->value</p>\n";
       }
       else {
-        $output .= "<p><strong>$field->title</strong><br />$field->value</p>\n";
+        $output .= '<p><strong>'. check_plain($field->title) ."</strong><br />$field->value</p>\n";
       }
     }
   }
diff -Naur drupal-5.0/modules/search/search.info drupal-5.23/modules/search/search.info
--- drupal-5.0/modules/search/search.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/search/search.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/search/search.install drupal-5.23/modules/search/search.install
--- drupal-5.0/modules/search/search.install	2006-09-01 09:40:08.000000000 +0200
+++ drupal-5.23/modules/search/search.install	2007-09-30 03:13:23.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: search.install,v 1.6 2006/09/01 07:40:08 drumm Exp $
+// $Id: search.install,v 1.6.2.1 2007/09/30 01:13:23 drumm Exp $
 
 /**
  * Implementation of hook_install().
@@ -71,4 +71,5 @@
   db_query('DROP TABLE {search_total}');
   variable_del('minimum_word_size');
   variable_del('overlap_cjk');
+  variable_del('search_cron_limit');
 }
diff -Naur drupal-5.0/modules/search/search.module drupal-5.23/modules/search/search.module
--- drupal-5.0/modules/search/search.module	2007-01-13 12:02:30.000000000 +0100
+++ drupal-5.23/modules/search/search.module	2009-09-16 06:27:01.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: search.module,v 1.209 2007/01/13 11:02:30 unconed Exp $
+// $Id: search.module,v 1.209.2.7 2009/09/16 04:27:01 drumm Exp $
 
 /**
  * @file
@@ -143,7 +143,6 @@
     $items[] = array('path' => 'search',
       'title' => t('Search'),
       'callback' => 'search_view',
-      'callback arguments' => array('node'),
       'access' => user_access('search content'),
       'type' => MENU_SUGGESTED_ITEM);
     $items[] = array('path' => 'admin/settings/search',
@@ -169,16 +168,13 @@
     // we dynamically add the keywords to the search tabs' paths.
     $keys = search_get_keys();
     $keys = strlen($keys) ? '/'. $keys : '';
-    foreach (module_implements('search') as $name) {
-      $title = module_invoke($name, 'search', 'name');
-      $items[] = array('path' => 'search/'. $name . $keys, 'title' => $title,
-        'callback' => 'search_view',
-        'callback arguments' => array($name),
-        // The search module only returns a title when the user is allowed to
-        // access that particular search type.
-        'access' => user_access('search content') && $title,
-        'type' => MENU_LOCAL_TASK,
-      );
+    foreach (module_list() as $name) {
+      if (module_hook($name, 'search') && $title = module_invoke($name, 'search', 'name')) {
+        $items[] = array('path' => 'search/'. $name . $keys, 'title' => $title,
+          'callback' => 'search_view',
+          'access' => user_access('search content'),
+          'type' => MENU_LOCAL_TASK);
+      }
     }
   }
 
@@ -215,7 +211,7 @@
     }
   }
   $count = format_plural($remaining, 'There is 1 item left to index.', 'There are @count items left to index.');
-  $percentage = ((int)min(100, 100 * ($total - $remaining) / max(1, $total))) . '%';
+  $percentage = ((int)min(100, 100 * ($total - $remaining) / max(1, $total))) .'%';
   $status = '<p><strong>'. t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) .' '. $count .'</strong></p>';
   $form['status'] = array('#type' => 'fieldset', '#title' => t('Indexing status'));
   $form['status']['status'] = array('#value' => $status);
@@ -367,7 +363,7 @@
 
   // With the exception of the rules above, we consider all punctuation,
   // marks, spacers, etc, to be a word boundary.
-  $text = preg_replace('/['. PREG_CLASS_SEARCH_EXCLUDE . ']+/u', ' ', $text);
+  $text = preg_replace('/['. PREG_CLASS_SEARCH_EXCLUDE .']+/u', ' ', $text);
 
   return $text;
 }
@@ -893,7 +889,9 @@
 /**
  * Menu callback; presents the search form and/or search results.
  */
-function search_view($type = '') {
+function search_view() {
+  $type = arg(1);
+
   // Search form submits with POST but redirects to GET. This way we can keep
   // the search query URL clean as a whistle:
   // search/type/keyword+keyword
@@ -976,6 +974,10 @@
  *   An HTML string containing the search form.
  */
 function search_form($action = '', $keys = '', $type = NULL, $prompt = NULL) {
+
+  // Add CSS
+  drupal_add_css(drupal_get_path('module', 'search') .'/search.css', 'module', 'all', FALSE);
+
   if (!$action) {
     $action = url('search/'. $type);
   }
@@ -1041,9 +1043,6 @@
     '#attributes' => array('title' => t('Enter the terms you wish to search for.')),
   );
   $form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
-  // Always go to the search page since the search form is not guaranteed to be
-  // on every page.
-  $form['#action'] = url('search/node');
   $form['#base'] = 'search_box_form';
 
   return $form;
@@ -1053,6 +1052,17 @@
  * Process a block search form submission.
  */
 function search_box_form_submit($form_id, $form_values) {
+  // The search form relies on control of the redirect destination for its
+  // functionality, so we override any static destination set in the request,
+  // for example by drupal_access_denied() or drupal_not_found()
+  // (see http://drupal.org/node/292565).
+  if (isset($_REQUEST['destination'])) {
+    unset($_REQUEST['destination']);
+  }
+  if (isset($_REQUEST['edit']['destination'])) {
+    unset($_REQUEST['edit']['destination']);
+  }
+
   return 'search/node/'. trim($form_values[$form_id .'_keys']);
 }
 
@@ -1074,8 +1084,6 @@
  * Perform a standard search on the given keys, and return the formatted results.
  */
 function search_data($keys = NULL, $type = 'node') {
-  // Add CSS
-  drupal_add_css(drupal_get_path('module', 'search') .'/search.css', 'module', 'all', FALSE);
 
   if (isset($keys)) {
     if (module_hook($type, 'search')) {
@@ -1167,7 +1175,7 @@
 
   // If we didn't find anything, return the beginning.
   if (count($ranges) == 0) {
-    return truncate_utf8($text, 256) . ' ...';
+    return truncate_utf8($text, 256) .' ...';
   }
 
   // Sort the text ranges by starting position.
@@ -1233,7 +1241,7 @@
   $output = ' <dt class="title"><a href="'. check_url($item['link']) .'">'. check_plain($item['title']) .'</a></dt>';
   $info = array();
   if ($item['type']) {
-    $info[] = $item['type'];
+    $info[] = check_plain($item['type']);
   }
   if ($item['user']) {
     $info[] = $item['user'];
@@ -1244,7 +1252,7 @@
   if (is_array($item['extra'])) {
     $info = array_merge($info, $item['extra']);
   }
-  $output .= ' <dd>'. ($item['snippet'] ? '<p>'. $item['snippet'] . '</p>' : '') . '<p class="search-info">' . implode(' - ', $info) .'</p></dd>';
+  $output .= ' <dd>'. ($item['snippet'] ? '<p>'. $item['snippet'] .'</p>' : '') .'<p class="search-info">'. implode(' - ', $info) .'</p></dd>';
   return $output;
 }
 
diff -Naur drupal-5.0/modules/statistics/statistics.info drupal-5.23/modules/statistics/statistics.info
--- drupal-5.0/modules/statistics/statistics.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/statistics/statistics.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/system/system.info drupal-5.23/modules/system/system.info
--- drupal-5.0/modules/system/system.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/system/system.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - required
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/system/system.install drupal-5.23/modules/system/system.install
--- drupal-5.0/modules/system/system.install	2007-01-11 00:22:34.000000000 +0100
+++ drupal-5.23/modules/system/system.install	2009-03-22 20:55:22.000000000 +0100
@@ -1,10 +1,9 @@
 <?php
-// $Id: system.install,v 1.69 2007/01/10 23:22:34 unconed Exp $
+// $Id: system.install,v 1.69.2.12 2009/03/22 19:55:22 drumm Exp $
 
-define('DRUPAL_MINIMUM_PHP',    '4.3.3');
+define('DRUPAL_MINIMUM_PHP',    '4.3.5');
 define('DRUPAL_MINIMUM_MYSQL',  '3.23.17'); // If using MySQL
-define('DRUPAL_MINIMUM_PGSQL',  '7.3');  // If using PostgreSQL
-define('DRUPAL_MINIMUM_APACHE', '1.3');  // If using Apache
+define('DRUPAL_MINIMUM_PGSQL',  '7.4');  // If using PostgreSQL
 
 /**
  * Test and report Drupal installation requirements.
@@ -24,34 +23,12 @@
     );
   }
 
-  // Test web server
+  // Web server information.
   $software = $_SERVER['SERVER_SOFTWARE'];
   $requirements['webserver'] = array(
     'title' => $t('Web server'),
     'value' => $software,
   );
-  // Use server info string, if present.
-  if ($software && preg_match('![0-9]!', $software)) {
-    list($server, $version) = split('[ /]', $software);
-    switch ($server) {
-      case 'Apache':
-        if (version_compare($version, DRUPAL_MINIMUM_APACHE) < 0) {
-          $requirements['webserver']['description'] = $t('Your Apache server is too old. Drupal requires at least Apache %version.', array('%version' => DRUPAL_MINIMUM_APACHE));
-          $requirements['webserver']['severity'] = REQUIREMENT_ERROR;
-        }
-        break;
-
-      default:
-        $requirements['webserver']['description'] = $t('The web server you\'re using has not been tested with Drupal and might not work properly.');
-        $requirements['webserver']['severity'] = REQUIREMENT_WARNING;
-        break;
-    }
-  }
-  else {
-    $requirements['webserver']['value'] = $software ? $software : $t('Unknown');
-    $requirements['webserver']['description'] = $t('Unable to determine your web server type and version. Drupal might not work properly.');
-    $requirements['webserver']['severity'] = REQUIREMENT_WARNING;
-  }
 
   // Test PHP version
   $requirements['php'] = array(
@@ -63,6 +40,25 @@
     $requirements['php']['severity'] = REQUIREMENT_ERROR;
   }
 
+  // Test PHP register_globals setting.
+  $requirements['php_register_globals'] = array(
+    'title' => $t('PHP register globals'),
+  );
+  $register_globals = trim(ini_get('register_globals'));
+  // Unfortunately, ini_get() may return many different values, and we can't
+  // be certain which values mean 'on', so we instead check for 'not off'
+  // since we never want to tell the user that their site is secure
+  // (register_globals off), when it is in fact on. We can only guarantee
+  // register_globals is off if the value returned is 'off', '', or 0.
+  if (!empty($register_globals) && strtolower($register_globals) != 'off') {
+    $requirements['php_register_globals']['description'] = $t('<em>register_globals</em> is enabled. Drupal requires this configuration directive to be disabled. Your site may not be secure when <em>register_globals</em> is enabled. The PHP manual has instructions for <a href="http://php.net/configuration.changes">how to change configuration settings</a>.');
+    $requirements['php_register_globals']['severity'] = REQUIREMENT_ERROR;
+    $requirements['php_register_globals']['value'] = $t("Enabled ('@value')", array('@value' => $register_globals));
+  }
+  else {
+    $requirements['php_register_globals']['value'] = $t('Disabled');
+  }
+
   // Test DB version
   global $db_type;
   if (function_exists('db_status_report')) {
@@ -551,6 +547,7 @@
         data longtext,
         PRIMARY KEY (uid),
         UNIQUE KEY name (name),
+        KEY created (created),
         KEY access (access)
       ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
 
@@ -674,7 +671,6 @@
 
       db_query("CREATE TABLE {boxes} (
         bid serial,
-        title varchar(64) NOT NULL default '',
         body text,
         info varchar(128) NOT NULL default '',
         format smallint NOT NULL default '0',
@@ -905,6 +901,8 @@
         UNIQUE (name)
       )");
 
+      db_query("SELECT setval('{role}_rid_seq',". max(DRUPAL_ANONYMOUS_RID,DRUPAL_AUTHENTICATED_RID) .")");
+
       db_query("CREATE TABLE {blocks_roles} (
         module varchar(64) NOT NULL,
         delta varchar(32) NOT NULL,
@@ -1019,6 +1017,7 @@
         UNIQUE (name)
       )");
       db_query("CREATE INDEX {users}_access_idx ON {users} (access)");
+      db_query("CREATE INDEX {users}_created_idx ON {users} (created)");
 
       db_query("CREATE TABLE {users_roles} (
         uid int_unsigned NOT NULL default '0',
@@ -1075,8 +1074,8 @@
 
   db_query("INSERT INTO {users} (uid,name,mail) VALUES(0,'','')");
 
-  db_query("INSERT INTO {role} (name) VALUES ('anonymous user')");
-  db_query("INSERT INTO {role} (name) VALUES ('authenticated user')");
+  db_query("INSERT INTO {role} (rid, name) VALUES (". DRUPAL_ANONYMOUS_RID .", 'anonymous user')");
+  db_query("INSERT INTO {role} (rid, name) VALUES (". DRUPAL_AUTHENTICATED_RID .", 'authenticated user')");
 
   db_query("INSERT INTO {permission} VALUES (1,'access content',0)");
   db_query("INSERT INTO {permission} VALUES (2,'access comments, access content, post comments, post comments without approval',0)");
@@ -1258,7 +1257,7 @@
   }
 
   // Flush the menu cache:
-  cache_clear_all('menu:', TRUE);
+  cache_clear_all('*', 'cache_menu', TRUE);
 
   return $ret;
 }
@@ -1405,7 +1404,7 @@
     list(, $page, $op, $uid) = explode('/', $alias->src);
     if ($page == 'feed') {
       $new = "blog/$uid/feed";
-      update_sql("UPDATE {url_alias} SET src = '%s' WHERE pid = '%s'", $new, $alias->pid);
+      db_query("UPDATE {url_alias} SET src = '%s' WHERE pid = %d", $new, $alias->pid);
     }
   }
 
@@ -3049,7 +3048,7 @@
   switch ($GLOBALS['db_type']) {
     case 'mysql':
     case 'mysqli':
-      $ret[] = update_sql("ALTER TABLE {profile_fields} ADD autocomplete TINYint NOT NULL AFTER visibility ;");
+      $ret[] = update_sql("ALTER TABLE {profile_fields} ADD autocomplete TINYint NOT NULL AFTER visibility");
       break;
     case 'pgsql':
       db_add_column($ret, 'profile_fields', 'autocomplete', 'smallint', array('not null' => TRUE, 'default' => 0));
@@ -3510,6 +3509,35 @@
 
 
 /**
+ * @defgroup updates-5.x-extra Extra system updates for 5.x
+ * @{
+ */
+
+/**
+ * Add index on users created column.
+ */
+function system_update_1022() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql('ALTER TABLE {users} ADD KEY created (created)');
+      break;
+
+    case 'pgsql':
+      $ret[] = update_sql("CREATE INDEX {users}_created_idx ON {users} (created)");
+      break;
+  }
+  // Also appears as system_update_2004(). Ensure we don't update twice.
+  variable_set('system_update_1022', TRUE);
+  return $ret;
+}
+
+/**
+ * @} End of "defgroup updates-5.x-extra"
+ */
+
+/**
  * @defgroup updates-5.0-to-x.x System updates from 5.0 to x.x
  * @{
  * @todo Start this series of updates at 2000.
diff -Naur drupal-5.0/modules/system/system.module drupal-5.23/modules/system/system.module
--- drupal-5.0/modules/system/system.module	2007-01-15 13:04:14.000000000 +0100
+++ drupal-5.23/modules/system/system.module	2010-08-11 22:37:49.000000000 +0200
@@ -1,12 +1,12 @@
 <?php
-// $Id: system.module,v 1.440.2.1 2007/01/15 12:04:14 unconed Exp $
+// $Id: system.module,v 1.440.2.63 2010/08/11 20:37:49 drumm Exp $
 
 /**
  * @file
  * Configuration system that lets administrators modify the workings of the site.
  */
 
-define('VERSION', '5.0');
+define('VERSION', '5.23');
 
 /**
  * Implementation of hook_help().
@@ -16,7 +16,7 @@
 
   switch ($section) {
     case 'admin/help#system':
-      $output = '<p>'. t('The system module provides system-wide defaults such as running jobs at a particular time, and storing web pages to improve efficiency. The ability to run scheduled jobs makes administering the web site more usable, as administrators do not have to manually start jobs. The storing of web pages, or caching, allows the site to efficiently re-use web pages and improve web site performance. The settings module provides control over preferences, behaviours including visual and operational settings.') .'</p>';
+      $output = '<p>'. t('The system module provides system-wide defaults such as running jobs at a particular time, and storing web pages to improve efficiency. The ability to run scheduled jobs makes administering the web site more usable, as administrators do not have to manually start jobs. The storing of web pages, or caching, allows the site to efficiently re-use web pages and improve web site performance. The system module provides control over preferences, behaviours including visual and operational settings.') .'</p>';
       $output .= '<p>'. t('Some modules require regularly scheduled actions, such as cleaning up logfiles. Cron, which stands for chronograph, is a periodic command scheduler executing commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period measured in seconds). The aggregator module periodically updates feeds using cron. Ping periodically notifies services of new content on your site. Search periodically indexes the content on your site. Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution. Cron can, if necessary, also be run manually.') .'</p>';
       $output .= '<p>'. t("There is a caching mechanism which stores dynamically generated web pages in a database. By caching a web page, the system module does not have to create the page each time someone wants to view it, instead it takes only one SQL query to display it, reducing response time and the server's load. Only pages requested by <em>anonymous</em> users are cached. In order to reduce server load and save bandwidth, the system module stores and sends cached pages compressed.") .'</p>';
       $output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="@system">System page</a>.', array('@system' => 'http://drupal.org/handbook/modules/system/')) .'</p>';
@@ -29,8 +29,8 @@
       return '<p>'. t('Select which themes are available to your users and specify the default theme. To configure site-wide display settings, click the "configure" task above. Alternately, to override these settings in a specific theme, click the "configure" link for the corresponding theme. Note that different themes may have different regions available for rendering content like blocks. If you want consistency in what your users see, you may wish to enable only one theme.') .'</p>';
     case 'admin/build/themes/settings':
       return '<p>'. t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') .'</p>';
-    case 'admin/build/themes/settings/'. arg(3):
-      $reference = explode('.', arg(3), 2);
+    case 'admin/build/themes/settings/'. arg(4):
+      $reference = explode('.', arg(4), 2);
       $theme = array_pop($reference);
       return '<p>'. t('These options control the display settings for the <code>%template</code> theme. When your site is displayed using this theme, these settings will be used. By clicking "Reset to defaults," you can choose to use the <a href="@global">global settings</a> for this theme.', array('%template' => $theme, '@global' => url('admin/build/themes/settings'))) .'</p>';
     case 'admin/build/modules':
@@ -79,7 +79,7 @@
   $type['value'] = array('#input' => TRUE);
   $type['markup'] = array('#prefix' => '', '#suffix' => '');
   $type['fieldset'] = array('#collapsible' => FALSE, '#collapsed' => FALSE);
-  $type['token'] = array('#input'=> TRUE);
+  $type['token'] = array('#input' => TRUE);
   return $type;
 }
 
@@ -458,7 +458,7 @@
   }
 }
 
-/*
+/**
  * Returns a fieldset containing the theme select form.
  *
  * @param $description
@@ -493,7 +493,7 @@
         // For the default theme, revert to an empty string so the user's theme updates when the site theme is changed.
         $info->key = $info->name == variable_get('theme_default', 'garland') ? '' : $info->name;
 
-        $info->screenshot = dirname($info->filename) . '/screenshot.png';
+        $info->screenshot = dirname($info->filename) .'/screenshot.png';
         $screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), FALSE) : t('no screenshot');
 
         $form['themes'][$info->key]['screenshot'] = array('#value' => $screenshot);
@@ -526,11 +526,11 @@
 
 function _system_zonelist() {
   $timestamp = time();
-  $zonelist = array(-11, -10, -9.5, -9, -8, -7, -6, -5, -4, -3.5, -3, -2, -1, 0, 1, 2, 3, 3.5, 4, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 14);
+  $zonelist = array(-11, -10, -9.5, -9, -8, -7, -6, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1, 0, 1, 2, 3, 3.5, 4, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 14);
   $zones = array();
   foreach ($zonelist as $offset) {
     $zone = $offset * 3600;
-    $zones[$zone] = format_date($timestamp, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone);
+    $zones[$zone] = format_date($timestamp, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') .' O', $zone);
   }
   return $zones;
 }
@@ -547,7 +547,8 @@
     '#type' => 'textfield',
     '#title' => t('E-mail address'),
     '#default_value' => variable_get('site_mail', ini_get('sendmail_from')),
-    '#description' => t('A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc.')
+    '#description' => t('A valid e-mail address to be used as the "From" address by the auto-mailer during registration, new password requests, notifications, etc.  To lessen the likelihood of e-mail being marked as spam, this e-mail address should use the same domain as the website.'),
+    '#required' => TRUE,
   );
   $form['site_slogan'] = array(
     '#type' => 'textfield',
@@ -598,7 +599,7 @@
 
   if (!variable_get('clean_url', 0)) {
     if (strpos(request_uri(), '?q=') !== FALSE) {
-      $form['clean_url']['#description'] .= t(' Before enabling clean URLs, you must perform a test to determine if your server is properly configured. If you are able to see this page again after clicking the "Run the clean URL test" link, the test has succeeded and the radio buttons above will be available. If instead you are directed to a "Page not found" error, you will need to change the configuration of your server. The <a href="@handbook">handbook page on Clean URLs</a> has additional troubleshooting information. !run-test', array('@handbook' => 'http://drupal.org/node/15365', '!run-test' => '<a href ="'. base_path() . 'admin/settings/clean-urls">'. t('Run the clean URL test') .'</a>'));
+      $form['clean_url']['#description'] .= t(' Before enabling clean URLs, you must perform a test to determine if your server is properly configured. If you are able to see this page again after clicking the "Run the clean URL test" link, the test has succeeded and the radio buttons above will be available. If instead you are directed to a "Page not found" error, you will need to change the configuration of your server. The <a href="@handbook">handbook page on Clean URLs</a> has additional troubleshooting information. !run-test', array('@handbook' => 'http://drupal.org/node/15365', '!run-test' => '<a href ="'. base_path() .'admin/settings/clean-urls">'. t('Run the clean URL test') .'</a>'));
       $form['clean_url']['#disabled'] = TRUE;
     }
     else {
@@ -657,7 +658,7 @@
   sort($problem_modules);
 
   if (count($problem_modules) > 0) {
-    $description .= '<p>'. t('<strong class="error">The following enabled modules are incompatible with aggressive mode caching and will not function properly: %modules</strong>', array('%modules' => implode(', ', $problem_modules))) .'.</p>';
+    $description .= '<p>'. t('<strong class="error">The following enabled modules are incompatible with aggressive mode caching and might not function properly: %modules</strong>', array('%modules' => implode(', ', $problem_modules))) .'.</p>';
   }
   else {
     $description .= '<p>'. t('<strong class="ok">Currently, all enabled modules are compatible with the aggressive caching policy.</strong> Please note, if you use aggressive caching and enable new modules, you will need to check this page again to ensure compatibility.') .'</p>';
@@ -697,7 +698,7 @@
   $form['bandwidth_optimizations']['preprocess_css'] = array(
     '#type' => 'radios',
     '#title' => t('Aggregate and compress CSS files'),
-    '#default_value' => variable_get('preprocess_css', FALSE) && $is_writable,
+    '#default_value' => intval(variable_get('preprocess_css', FALSE) && $is_writable),
     '#disabled' => !$is_writable,
     '#options' => array(t('Disabled'), t('Enabled')),
     '#description' => t("Some Drupal modules include their own CSS files. When these modules are enabled, each module's CSS file adds an additional HTTP request to the page, which can increase the load time of each page. These HTTP requests can also slightly increase server load. It is recommended to only turn this option on when your site is in production, as it can interfere with theme development. This option is disabled if you have not set up your files directory, or if your download method is set to private."),
@@ -769,7 +770,7 @@
   $form['feed_item_length'] = array(
     '#type' => 'select',
     '#title' => t('Display of XML feed items'),
-    '#default_value' => variable_get('feed_item_length','teaser'),
+    '#default_value' => variable_get('feed_item_length', 'teaser'),
     '#options' => array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')),
     '#description' => t('Global setting for the length of XML feed items that are output by default.')
   );
@@ -938,7 +939,7 @@
     db_query("INSERT INTO {system} (name, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', %d, %d, %d)", $engine->name, 'theme_engine', $engine->filename, 1, 0, 0);
 
     // Add templates to the site listing
-    foreach (call_user_func($engine->name . '_templates') as $template) {
+    foreach (call_user_func($engine->name .'_templates') as $template) {
       // Do not double-insert templates with theme files in their directory,
       // but do register their engine data.
       if (array_key_exists($template->name, $themes)) {
@@ -1005,21 +1006,21 @@
     }
 
     // If this is a custom theme, load it in before moving on.
-    if (file_exists($file = dirname($theme->filename) .'/' . $theme_key . '.theme')) {
+    if (file_exists($file = dirname($theme->filename) .'/'. $theme_key .'.theme')) {
       include_once "./$file";
     }
 
     $regions = array();
 
     // This theme has defined its own regions.
-    if (function_exists($theme_key . '_regions')) {
-      $regions = call_user_func($theme_key . '_regions');
+    if (function_exists($theme_key .'_regions')) {
+      $regions = call_user_func($theme_key .'_regions');
     }
     // File is an engine; include its regions.
     else if (strpos($theme->description, '.engine')) {
-      include_once './' . $theme->description;
+      include_once './'. $theme->description;
       $theme_engine = basename($theme->description, '.engine');
-      $regions = function_exists($theme_engine . '_regions') ? call_user_func($theme_engine . '_regions') : array();
+      $regions = function_exists($theme_engine .'_regions') ? call_user_func($theme_engine .'_regions') : array();
     }
 
     $list[$theme_key] = $regions;
@@ -1146,7 +1147,7 @@
   ksort($themes);
 
   foreach ($themes as $info) {
-    $info->screenshot = dirname($info->filename) . '/screenshot.png';
+    $info->screenshot = dirname($info->filename) .'/screenshot.png';
     $screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), FALSE) : t('no screenshot');
 
     $form[$info->name]['screenshot'] = array('#value' => $screenshot);
@@ -1155,8 +1156,8 @@
     if ($info->status) {
       $status[] = $info->name;
     }
-    if ($info->status && (function_exists($info->prefix . '_settings') || function_exists($info->prefix . '_features'))) {
-      $form[$info->name]['operations'] = array('#value' => l(t('configure'), 'admin/build/themes/settings/' . $info->name) );
+    if ($info->status && (function_exists($info->prefix .'_settings') || function_exists($info->prefix .'_features'))) {
+      $form[$info->name]['operations'] = array('#value' => l(t('configure'), 'admin/build/themes/settings/'. $info->name) );
     }
     else {
       // Dummy element for drupal_render. Cleaner than adding a check in the theme function.
@@ -1233,7 +1234,7 @@
  * Modules can be enabled or disabled and set for throttling if the throttle module is enabled.
  * The list of modules gets populated by module.info files, which contain each module's name,
  * description and dependencies.
- * @sa _module_parse_info_file for information on module.info descriptors.
+ * @see _module_parse_info_file for information on module.info descriptors.
  *
  * Dependency checking is performed to ensure that a module cannot be enabled if the module has
  * disabled dependencies and also to ensure that the module cannot be disabled if the module has
@@ -1245,6 +1246,9 @@
 function system_modules($form_values = NULL) {
   // Get current list of modules.
   $files = module_rebuild_cache();
+
+  uasort($files, 'system_sort_modules_by_info_name');
+
   if ($confirm_form = system_modules_confirm_form($files, $form_values)) {
     return $confirm_form;
   }
@@ -1315,7 +1319,7 @@
     }
 
     // Add text for enabled dependents.
-    if (!empty($dependents)){
+    if (!empty($dependents)) {
       $form['description'][$filename]['required'] = array(
         '#value' => t('Required by: !required', array('!required' => implode(', ', $dependents))),
         '#prefix' => '<div class="admin-required">',
@@ -1367,6 +1371,10 @@
   return $form;
 }
 
+function system_sort_modules_by_info_name($a, $b) {
+  return strcasecmp($a->info['name'], $b->info['name']);
+}
+
 /**
  * Form process callback function to disable check boxes.
  */
@@ -1424,11 +1432,11 @@
 function system_module_build_dependencies($modules, $form_values) {
   static $dependencies;
 
-  if (!isset($dependencies) && isset($form_values)) {
+  if (!isset($dependencies) && isset($form_values) && is_array($form_values)) {
     $dependencies = array();
     foreach ($modules as $name => $module) {
       // If the module is disabled, will be switched on and it has dependencies.
-      if (!$module->status && $form_values['status'][$name] && isset($module->info['dependencies'])) {
+      if (!$module->status && isset($form_values['status'][$name]) && $form_values['status'][$name] && isset($module->info['dependencies'])) {
         foreach ($module->info['dependencies'] as $dependency) {
           if (!$form_values['status'][$dependency] && isset($modules[$dependency])) {
             if (!isset($dependencies[$name])) {
@@ -1541,7 +1549,7 @@
   $modules = $form['validation_modules']['#value'];
   foreach ($modules as $module) {
     if (!isset($module->info['package']) || !$module->info['package']) {
-      $module->info['package'] = 'Other';
+      $module->info['package'] = t('Other');
     }
     $packages[$module->info['package']][$module->name] = $module->info;
   }
@@ -1916,7 +1924,7 @@
     $settings = theme_get_settings($key);
     $var = str_replace('/', '_', 'theme_'. $key .'_settings');
     $themes = system_theme_data();
-    $features = function_exists($themes[$key]->prefix . '_features') ? call_user_func($themes[$key]->prefix . '_features') : array();
+    $features = function_exists($themes[$key]->prefix .'_features') ? call_user_func($themes[$key]->prefix .'_features') : array();
   }
   else {
     $settings = theme_get_settings('');
@@ -1929,7 +1937,7 @@
   if ($file = file_check_upload('logo_upload')) {
     if ($info = image_get_info($file->filepath)) {
       $parts = pathinfo($file->filename);
-      $filename = ($key) ? str_replace('/', '_', $key) . '_logo.' . $parts['extension'] : 'logo.' . $parts['extension'];
+      $filename = ($key) ? str_replace('/', '_', $key) .'_logo.'. $parts['extension'] : 'logo.'. $parts['extension'];
 
       if ($file = file_save_upload('logo_upload', $filename, 1)) {
         $_POST['default_logo'] = 0;
@@ -1945,7 +1953,7 @@
   // Check for a new uploaded favicon, and use that instead.
   if ($file = file_check_upload('favicon_upload')) {
     $parts = pathinfo($file->filename);
-    $filename = ($key) ? str_replace('/', '_', $key) . '_favicon.' . $parts['extension'] : 'favicon.' . $parts['extension'];
+    $filename = ($key) ? str_replace('/', '_', $key) .'_favicon.'. $parts['extension'] : 'favicon.'. $parts['extension'];
 
     if ($file = file_save_upload('favicon_upload', $filename, 1)) {
       $_POST['default_favicon'] = 0;
@@ -2010,7 +2018,7 @@
         '#suffix' => '</div>',
       );
       foreach ($node_types as $type => $name) {
-        $form['node_info']["toggle_node_info_$type"] = array('#type' => 'checkbox', '#title' => $name, '#default_value' => $settings["toggle_node_info_$type"]);
+        $form['node_info']["toggle_node_info_$type"] = array('#type' => 'checkbox', '#title' => check_plain($name), '#default_value' => $settings["toggle_node_info_$type"]);
       }
     }
   }
@@ -2046,8 +2054,11 @@
 
   // Icon settings
   if ((!$key) || in_array('toggle_favicon', $features)) {
-    $form['favicon'] = array('#type' => 'fieldset', '#title' => t('Shortcut icon settings'));
-    $form['favicon']['text'] = array('#value' => t('Your shortcut icon or \'favicon\' is displayed in the address bar and bookmarks of most browsers.'));
+    $form['favicon'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Shortcut icon settings'),
+      '#description' => t("Your shortcut icon or 'favicon' is displayed in the address bar and bookmarks of most browsers.")
+    );
     $form['favicon']['default_favicon'] = array(
       '#type' => 'checkbox',
       '#title' => t('Use the default shortcut icon.'),
@@ -2112,12 +2123,12 @@
  * Output a confirmation form
  *
  * This function returns a complete form for confirming an action. A link is
- * offered to go back to the item that is being changed in case the user changes
- * his/her mind.
+ * offered to go back to the item that is being changed in case the user 
+ * changes his/her mind.
  *
- * You can check for the existence of $_POST[$name] (where $name
- * is usually 'confirm') to check if the confirmation was successful or
- * use the regular submit model.
+ * If the submit handler for this form is invoked, the user successfully
+ * confirmed the action. You should never directly inspect $_POST to see if an
+ * action was confirmed.
  *
  * @param $form
  *   Additional elements to inject into the form, for example hidden elements.
@@ -2152,6 +2163,7 @@
   $cancel = l($no ? $no : t('Cancel'), $path, array(), $query, $fragment);
 
   drupal_set_title($question);
+
   $form['#attributes'] = array('class' => 'confirmation');
   $form['description'] = array('#value' => $description);
   $form[$name] = array('#type' => 'hidden', '#value' => 1);
@@ -2359,7 +2371,7 @@
     }
   }
 
-  $output = '<div class="admin">';
+  $output = '<div class="admin clear-block">';
   foreach ($container as $id => $data) {
     $output .= '<div class="'. $id .' clear-block">';
     $output .= $data;
diff -Naur drupal-5.0/modules/taxonomy/taxonomy.info drupal-5.23/modules/taxonomy/taxonomy.info
--- drupal-5.0/modules/taxonomy/taxonomy.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/taxonomy/taxonomy.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/taxonomy/taxonomy.module drupal-5.23/modules/taxonomy/taxonomy.module
--- drupal-5.0/modules/taxonomy/taxonomy.module	2007-01-11 04:29:15.000000000 +0100
+++ drupal-5.23/modules/taxonomy/taxonomy.module	2009-07-10 07:47:16.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: taxonomy.module,v 1.330 2007/01/11 03:29:15 unconed Exp $
+// $Id: taxonomy.module,v 1.330.2.21 2009/07/10 05:47:16 drumm Exp $
 
 /**
  * @file
@@ -57,7 +57,6 @@
  * @return
  *   An internal Drupal path.
  */
-
 function taxonomy_term_path($term) {
   $vocabulary = taxonomy_get_vocabulary($term->vid);
   if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) {
@@ -152,7 +151,7 @@
     $types = array();
     foreach ($vocabulary->nodes as $type) {
       $node_type = node_get_types('name', $type);
-      $types[] = $node_type ? $node_type : $type;
+      $types[] = $node_type ? check_plain($node_type) : check_plain($type);
     }
     $rows[] = array('name' => check_plain($vocabulary->name),
       'type' => implode(', ', $types),
@@ -188,28 +187,42 @@
   $page_increment  = 25; // number of tids per page
   $displayed_count = 0;  // number of tids shown
 
-  $tree = taxonomy_get_tree($vocabulary->vid);
-  foreach ($tree as $term) {
-    $total_entries++; // we're counting all-totals, not displayed
-    if (($start_from && ($start_from * $page_increment) >= $total_entries) || ($displayed_count == $page_increment)) {
-      continue;
+  if ($vocabulary->tags) {
+    // We are not calling taxonomy_get_tree because that might fail with a big
+    // number of tags in the freetagging vocabulary.
+    $results = pager_query(db_rewrite_sql('SELECT t.*, h.parent FROM {term_data} t INNER JOIN  {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $page_increment, 0, NULL, $vid);
+    while ($term = db_fetch_object($results)) {
+      $rows[] = array(
+        l($term->name, "taxonomy/term/$term->tid"),
+        l(t('edit'), "admin/content/taxonomy/edit/term/$term->tid", array(), $destination),
+      );
     }
-    $rows[] = array(str_repeat('--', $term->depth) . ' ' . l($term->name, "taxonomy/term/$term->tid"), l(t('edit'), "admin/content/taxonomy/edit/term/$term->tid", array(), $destination));
-    $displayed_count++; // we're counting tids displayed
   }
+  else {
+    $tree = taxonomy_get_tree($vocabulary->vid);
+    foreach ($tree as $term) {
+      $total_entries++; // we're counting all-totals, not displayed
+      if (($start_from && ($start_from * $page_increment) >= $total_entries) || ($displayed_count == $page_increment)) {
+        continue;
+      }
+      $rows[] = array(str_repeat('--', $term->depth) .' '. l($term->name, "taxonomy/term/$term->tid"), l(t('edit'), "admin/content/taxonomy/edit/term/$term->tid", array(), $destination));
+      $displayed_count++; // we're counting tids displayed
+    }
 
-  if (!$rows) {
-    $rows[] = array(array('data' => t('No terms available.'), 'colspan' => '2'));
-  }
+    if (!$rows) {
+      $rows[] = array(array('data' => t('No terms available.'), 'colspan' => '2'));
+    }
 
-  $GLOBALS['pager_page_array'][] = $start_from;  // FIXME
-  $GLOBALS['pager_total'][] = intval($total_entries / $page_increment) + 1; // FIXME
+    $GLOBALS['pager_page_array'][] = $start_from;  // FIXME
+    $GLOBALS['pager_total'][] = intval($total_entries / $page_increment) + 1; // FIXME
+  }
 
-  if ($total_entries >= $page_increment) {
-    $rows[] = array(array('data' => theme('pager', NULL, $page_increment), 'colspan' => '2'));
+  $output .= theme('table', $header, $rows, array('id' => 'taxonomy'));
+  if ($vocabulary->tags || $total_entries >= $page_increment) {
+    $output .= theme('pager', NULL, $page_increment);
   }
 
-  return theme('table', $header, $rows, array('id' => 'taxonomy'));
+  return $output;
 }
 
 /**
@@ -219,7 +232,7 @@
   $form['name'] = array('#type' => 'textfield',
     '#title' => t('Vocabulary name'),
     '#default_value' => $edit['name'],
-    '#maxlength' => 64,
+    '#maxlength' => 255,
     '#description' => t('The name for this vocabulary. Example: "Topic".'),
     '#required' => TRUE,
   );
@@ -230,13 +243,14 @@
   );
   $form['help'] = array('#type' => 'textfield',
     '#title' => t('Help text'),
+    '#maxlength' => 255,
     '#default_value' => $edit['help'],
     '#description' => t('Instructions to present to the user when choosing a term.'),
   );
   $form['nodes'] = array('#type' => 'checkboxes',
     '#title' => t('Types'),
     '#default_value' => $edit['nodes'],
-    '#options' => node_get_types('names'),
+    '#options' => array_map('check_plain', node_get_types('names')),
     '#description' => t('A list of node types you want to associate with this vocabulary.'),
     '#required' => TRUE,
   );
@@ -290,9 +304,11 @@
   switch (taxonomy_save_vocabulary($form_values)) {
     case SAVED_NEW:
       drupal_set_message(t('Created new vocabulary %name.', array('%name' => $form_values['name'])));
+      watchdog('taxonomy', t('Created new vocabulary %name.', array('%name' => $form_values['name'])), WATCHDOG_NOTICE, l(t('edit'), 'admin/content/taxonomy/edit/vocabulary/'. $form_values['vid']));
       break;
     case SAVED_UPDATED:
       drupal_set_message(t('Updated vocabulary %name.', array('%name' => $form_values['name'])));
+      watchdog('taxonomy', t('Updated vocabulary %name.', array('%name' => $form_values['name'])), WATCHDOG_NOTICE, l(t('edit'), 'admin/content/taxonomy/edit/vocabulary/'. $form_values['vid']));
       break;
   }
   return 'admin/content/taxonomy';
@@ -371,17 +387,19 @@
 function taxonomy_vocabulary_confirm_delete_submit($form_id, $form_values) {
   $status = taxonomy_del_vocabulary($form_values['vid']);
   drupal_set_message(t('Deleted vocabulary %name.', array('%name' => $form_values['name'])));
+  watchdog('taxonomy', t('Deleted vocabulary %name.', array('%name' => $form_values['name'])), WATCHDOG_NOTICE);
   return 'admin/content/taxonomy';
 }
 
 function taxonomy_form_term($vocabulary_id, $edit = array()) {
   $vocabulary = taxonomy_get_vocabulary($vocabulary_id);
+  drupal_set_title(check_plain($vocabulary->name));
 
   $form['name'] = array(
     '#type' => 'textfield',
     '#title' => t('Term name'),
     '#default_value' => $edit['name'],
-    '#maxlength' => 64,
+    '#maxlength' => 255,
     '#description' => t('The name of this term.'),
     '#required' => TRUE);
 
@@ -452,9 +470,11 @@
   switch (taxonomy_save_term($form_values)) {
     case SAVED_NEW:
       drupal_set_message(t('Created new term %term.', array('%term' => $form_values['name'])));
+      watchdog('taxonomy', t('Created new term %term.', array('%term' => $form_values['name'])), WATCHDOG_NOTICE, l(t('edit'), 'admin/content/taxonomy/edit/term/'. $form_values['tid']));
       break;
     case SAVED_UPDATED:
-      drupal_set_message(t('The term %term has been updated.', array('%term' => $form_values['name'])));
+      drupal_set_message(t('Updated term %term.', array('%term' => $form_values['name'])));
+      watchdog('taxonomy', t('Updated term %term.', array('%term' => $form_values['name'])), WATCHDOG_NOTICE, l(t('edit'), 'admin/content/taxonomy/edit/term/'. $form_values['tid']));
       break;
   }
   return 'admin/content/taxonomy';
@@ -591,6 +611,7 @@
 function taxonomy_term_confirm_delete_submit($form_id, $form_values) {
   taxonomy_del_term($form_values['tid']);
   drupal_set_message(t('Deleted term %name.', array('%name' => $form_values['name'])));
+  watchdog('taxonomy', t('Deleted term %name.', array('%name' => $form_values['name'])), WATCHDOG_NOTICE);
   return 'admin/content/taxonomy';
 }
 
@@ -599,12 +620,13 @@
  */
 function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') {
   $vocabulary = taxonomy_get_vocabulary($vid);
-  $help = ($help) ? $help : $vocabulary->help;
-  if ($vocabulary->required) {
-    $blank = 0;
+  $help = ($help) ? $help : filter_xss_admin($vocabulary->help);
+
+  if (!$vocabulary->multiple) {
+    $blank = ($vocabulary->required) ? t('- Please choose -') : t('- None selected -');
   }
   else {
-    $blank = '<'. t('none') .'>';
+    $blank = ($vocabulary->required) ? 0 : t('- None -');
   }
 
   return _taxonomy_term_select(check_plain($vocabulary->name), $name, $value, $vid, $help, intval($vocabulary->multiple), $blank);
@@ -619,7 +641,7 @@
   foreach ($vocabularies as $vid => $vocabulary) {
     if ($vocabulary->tags && !$free_tags) { continue; }
     $tree = taxonomy_get_tree($vid);
-    if ($tree && (count($tree) > 1)) {
+    if ($tree && (count($tree) > 0)) {
       $options[$vocabulary->name] = array();
       foreach ($tree as $term) {
         $options[$vocabulary->name][$term->tid] = str_repeat('-', $term->depth) . $term->name;
@@ -695,7 +717,7 @@
         $typed_string = implode(', ', $typed_terms) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL);
 
         if ($vocabulary->help) {
-          $help = $vocabulary->help;
+          $help = filter_xss_admin($vocabulary->help);
         }
         else {
           $help = t('A comma-separated list of terms describing this content. Example: funny, bungee jumping, "Company, Inc.".');
@@ -707,7 +729,7 @@
           '#default_value' => $typed_string,
           '#autocomplete_path' => 'taxonomy/autocomplete/'. $vocabulary->vid,
           '#weight' => $vocabulary->weight,
-          '#maxlength' => 255,
+          '#maxlength' => 1024,
         );
       }
       else {
@@ -718,7 +740,7 @@
             $default_terms[$term->tid] = $term;
           }
         }
-        $form['taxonomy'][$vocabulary->vid] = taxonomy_form($vocabulary->vid, array_keys($default_terms), $vocabulary->help);
+        $form['taxonomy'][$vocabulary->vid] = taxonomy_form($vocabulary->vid, array_keys($default_terms), filter_xss_admin($vocabulary->help));
         $form['taxonomy'][$vocabulary->vid]['#weight'] = $vocabulary->weight;
         $form['taxonomy'][$vocabulary->vid]['#required'] = $vocabulary->required;
       }
@@ -756,14 +778,14 @@
 function taxonomy_node_get_terms($nid, $key = 'tid') {
   static $terms;
 
-  if (!isset($terms[$nid])) {
+  if (!isset($terms[$nid][$key])) {
     $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.nid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $nid);
-    $terms[$nid] = array();
+    $terms[$nid][$key] = array();
     while ($term = db_fetch_object($result)) {
-      $terms[$nid][$term->$key] = $term;
+      $terms[$nid][$key][$term->$key] = $term;
     }
   }
-  return $terms[$nid];
+  return $terms[$nid][$key];
 }
 
 /**
@@ -1051,6 +1073,7 @@
     else {
       $result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type);
     }
+    $count[$type] = array();
     while ($term = db_fetch_object($result)) {
       $count[$type][$term->tid] = $term->c;
     }
@@ -1099,7 +1122,7 @@
  *   An array of matching term objects.
  */
 function taxonomy_get_term_by_name($name) {
-  $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER('%s') LIKE LOWER(t.name)", 't', 'tid'), trim($name));
+  $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER('%s') = LOWER(t.name)", 't', 'tid'), trim($name));
   $result = array();
   while ($term = db_fetch_object($db_result)) {
     $result[] = $term;
@@ -1154,12 +1177,41 @@
   return $terms[$tid];
 }
 
+/**
+ * Create a select form element for a given taxonomy vocabulary.
+ *
+ * NOTE: This function expects input that has already been sanitized and is
+ * safe for display. Callers must properly sanitize the $title and
+ * $description arguments to prevent XSS vulnerabilities.
+ *
+ * @param $title
+ *   The title of the vocabulary. This MUST be sanitized by the caller.
+ * @param $name
+ *   Ignored.
+ * @param $value
+ *   The currently selected terms from this vocabulary, if any.
+ * @param $vocabulary_id
+ *   The vocabulary ID to build the form element for.
+ * @param $description
+ *   Help text for the form element. This MUST be sanitized by the caller.
+ * @param $multiple
+ *   Boolean to control if the form should use a single or multiple select.
+ * @param $blank
+ *   Optional form choice to use when no value has been selected.
+ * @param $exclude
+ *   Optional array of term ids to exclude in the selector.
+ * @return
+ *   A FAPI form array to select terms from the given vocabulary.
+ *
+ * @see taxonomy_form()
+ * @see taxonomy_form_term()
+ */
 function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) {
   $tree = taxonomy_get_tree($vocabulary_id);
   $options = array();
 
   if ($blank) {
-    $options[0] = $blank;
+    $options[''] = $blank;
   }
   if ($tree) {
     foreach ($tree as $term) {
@@ -1169,10 +1221,6 @@
         $options[] = $choice;
       }
     }
-    if (!$blank && !$value) {
-      // required but without a predefined value, so set first as predefined
-      $value = $tree[0]->tid;
-    }
   }
 
   return array('#type' => 'select',
@@ -1226,27 +1274,31 @@
     }
 
     if ($operator == 'or') {
-      $str_tids = implode(',', call_user_func_array('array_merge', $descendant_tids));
-      $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 ORDER BY '. $order;
-      $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1';
+      $args = call_user_func_array('array_merge', $descendant_tids);
+      $placeholders = implode(',', array_fill(0, count($args), '%d'));
+      $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $placeholders .') AND n.status = 1 ORDER BY '. $order;
+      $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $placeholders .') AND n.status = 1';
     }
     else {
       $joins = '';
       $wheres = '';
+      $args = array();
       foreach ($descendant_tids as $index => $tids) {
         $joins .= ' INNER JOIN {term_node} tn'. $index .' ON n.nid = tn'. $index .'.nid';
-        $wheres .= ' AND tn'. $index .'.tid IN ('. implode(',', $tids) .')';
+        $placeholders = implode(',', array_fill(0, count($tids), '%d'));
+        $wheres .= ' AND tn'. $index .'.tid IN ('. $placeholders .')';
+        $args = array_merge($args, $tids);
       }
       $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres .' ORDER BY '. $order;
-      $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' WHERE n.status = 1 ' . $wheres;
+      $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres;
     }
     $sql = db_rewrite_sql($sql);
     $sql_count = db_rewrite_sql($sql_count);
     if ($pager) {
-      $result = pager_query($sql, variable_get('default_nodes_main', 10), 0, $sql_count);
+      $result = pager_query($sql, variable_get('default_nodes_main', 10), 0, $sql_count, $args);
     }
     else {
-      $result = db_query_range($sql, 0, variable_get('feed_default_items', 10));
+      $result = db_query_range($sql, $args, 0, variable_get('feed_default_items', 10));
     }
   }
 
@@ -1258,6 +1310,7 @@
  * taxonomy_select_nodes(), and formats each node along with a pager.
 */
 function taxonomy_render_nodes($result) {
+  $output = '';
   if (db_num_rows($result) > 0) {
     while ($node = db_fetch_object($result)) {
       $output .= node_view(node_load($node->nid), 1);
@@ -1346,7 +1399,8 @@
   }
 
   if ($terms['tids']) {
-    $result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN (%s)', 't', 'tid'), implode(',', $terms['tids']));
+    $placeholders = implode(',', array_fill(0, count($terms['tids']), '%d'));
+    $result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN ('. $placeholders .')', 't', 'tid'), $terms['tids']);
     $tids = array(); // we rebuild the $tids-array so it only contains terms the user has access to.
     $names = array();
     while ($term = db_fetch_object($result)) {
diff -Naur drupal-5.0/modules/throttle/throttle.info drupal-5.23/modules/throttle/throttle.info
--- drupal-5.0/modules/throttle/throttle.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/throttle/throttle.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/tracker/tracker.info drupal-5.23/modules/tracker/tracker.info
--- drupal-5.0/modules/tracker/tracker.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/tracker/tracker.info	2010-08-11 22:46:30.000000000 +0200
@@ -1,10 +1,12 @@
-; $Id: tracker.info,v 1.3 2006/11/21 20:55:35 dries Exp $
+; $Id: tracker.info,v 1.3.2.1 2007/07/09 03:33:58 drumm Exp $
 name = Tracker
 description = Enables tracking of recent posts for users.
+dependencies = comment
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/tracker/tracker.module drupal-5.23/modules/tracker/tracker.module
--- drupal-5.0/modules/tracker/tracker.module	2007-01-10 16:17:51.000000000 +0100
+++ drupal-5.23/modules/tracker/tracker.module	2007-07-26 21:16:50.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: tracker.module,v 1.143 2007/01/10 15:17:51 dries Exp $
+// $Id: tracker.module,v 1.143.2.2 2007/07/26 19:16:50 drumm Exp $
 
 /**
  * @file
@@ -96,7 +96,7 @@
   while ($node = db_fetch_object($result)) {
     // Determine the number of comments:
     $comments = 0;
-    if (module_exists('comment') && $node->comment_count) {
+    if ($node->comment_count) {
       $comments = $node->comment_count;
 
       if ($new = comment_num_new($node->nid)) {
@@ -106,7 +106,7 @@
     }
 
     $rows[] = array(
-      node_get_types('name', $node->type),
+      check_plain(node_get_types('name', $node->type)),
       l($node->title, "node/$node->nid") .' '. theme('mark', node_mark($node->nid, $node->changed)),
       theme('username', $node),
       array('class' => 'replies', 'data' => $comments),
diff -Naur drupal-5.0/modules/upload/upload.info drupal-5.23/modules/upload/upload.info
--- drupal-5.0/modules/upload/upload.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/upload/upload.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - optional
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/upload/upload.module drupal-5.23/modules/upload/upload.module
--- drupal-5.0/modules/upload/upload.module	2007-01-15 12:22:34.000000000 +0100
+++ drupal-5.23/modules/upload/upload.module	2010-08-11 22:37:49.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: upload.module,v 1.148 2007/01/15 11:22:34 unconed Exp $
+// $Id: upload.module,v 1.148.2.6 2010/08/11 20:37:49 drumm Exp $
 
 /**
  * @file
@@ -117,7 +117,7 @@
   $default_uploadsize = $form_values['upload_uploadsize_default'];
   $default_usersize = $form_values['upload_usersize_default'];
 
-  $exceed_max_msg = t('Your PHP settings limit the maximum file size per upload to %size MB.', array('%size' => file_upload_max_size())).'<br/>';
+  $exceed_max_msg = t('Your PHP settings limit the maximum file size per upload to %size.', array('%size' => format_size(file_upload_max_size()))).'<br/>';
   $more_info = t("Depending on your sever environment, these settings may be changed in the system-wide php.ini file, a php.ini file in your Drupal root directory, in your Drupal site's settings.php file, or in the .htaccess file in your Drupal root directory.");
 
   if (!is_numeric($default_uploadsize) || ($default_uploadsize <= 0)) {
@@ -126,7 +126,7 @@
   if (!is_numeric($default_usersize) || ($default_usersize <= 0)) {
     form_set_error('upload_usersize_default', t('The %role file size limit must be a number and greater than zero.', array('%role' => t('default'))));
   }
-  if ($default_uploadsize > file_upload_max_size()) {
+  if ($default_uploadsize * 1024 * 1024 > file_upload_max_size()) {
    form_set_error('upload_uploadsize_default', $exceed_max_msg . $more_info);
    $more_info = '';
   }
@@ -144,7 +144,7 @@
     if (!is_numeric($usersize) || ($usersize <= 0)) {
       form_set_error('upload_usersize_'. $rid, t('The %role file size limit must be a number and greater than zero.', array('%role' => $role)));
     }
-    if ($uploadsize > file_upload_max_size()) {
+    if ($uploadsize * 1024 * 1024 > file_upload_max_size()) {
      form_set_error('upload_uploadsize_'. $rid, $exceed_max_msg . $more_info);
      $more_info = '';
     }
@@ -158,7 +158,7 @@
  * Menu callback for the upload settings form.
  */
 function upload_admin_settings() {
-  $upload_extensions_default = variable_get('upload_extensions_default', 'jpg jpeg gif png txt html doc xls pdf ppt pps odt ods odp');
+  $upload_extensions_default = variable_get('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
   $upload_uploadsize_default = variable_get('upload_uploadsize_default', 1);
   $upload_usersize_default = variable_get('upload_usersize_default', 1);
 
@@ -259,9 +259,15 @@
 }
 
 function upload_file_download($file) {
-  $file = file_create_path($file);
-  $result = db_query("SELECT f.* FROM {files} f WHERE filepath = '%s'", $file);
-  if ($file = db_fetch_object($result)) {
+  $filepath = file_create_path($file);
+  $result = db_query("SELECT f.* FROM {files} f WHERE filepath = '%s'", $filepath);
+  while ($file = db_fetch_object($result)) {
+    if ($filepath !== $file->filepath) {
+      // Since some database servers sometimes use a case-insensitive
+      // comparison by default, double check that the filename is an exact
+      // match.
+      continue;
+    }
     if (user_access('view uploaded files')) {
       $node = node_load($file->nid);
       if (node_access('view', $node)) {
@@ -271,13 +277,8 @@
           'Content-Length: '. $file->filesize,
         );
       }
-      else {
-        return -1;
-      }
-    }
-    else {
-      return -1;
     }
+    return -1;
   }
 }
 
@@ -421,7 +422,7 @@
           $total_usersize = upload_space_used($user->uid) + $filesize;
           $error = array();
           foreach ($user->roles as $rid => $name) {
-            $extensions = variable_get("upload_extensions_$rid", variable_get('upload_extensions_default', 'jpg jpeg gif png txt html doc xls pdf ppt pps odt ods odp'));
+            $extensions = variable_get("upload_extensions_$rid", variable_get('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'));
             $uploadsize = variable_get("upload_uploadsize_$rid", variable_get('upload_uploadsize_default', 1)) * 1024 * 1024;
             $usersize = variable_get("upload_usersize_$rid", variable_get('upload_usersize_default', 1)) * 1024 * 1024;
 
@@ -582,8 +583,10 @@
   $header = array(t('Attachment'), t('Size'));
   $rows = array();
   foreach ($files as $file) {
-    if ($file->list) {
-      $href = $file->fid ? file_create_url($file->filepath) : url(file_create_filename($file->filename, file_create_path()));
+    $file = (object)$file;
+    if ($file->list && !$file->remove) {
+      // Generate valid URL for both existing attachments and preview of new attachments (these have 'upload' in fid)
+      $href = file_create_url((strpos($file->fid, 'upload') === FALSE ? $file->filepath : file_create_filename($file->filename, file_create_path())));
       $text = $file->description ? $file->description : $file->filename;
       $rows[] = array(l($text, $href), format_size($file->filesize));
     }
@@ -639,7 +642,7 @@
     if (!isset($extensions)) {
       $extensions = '';
       foreach ($user->roles as $rid => $name) {
-        $extensions .= ' '. variable_get("upload_extensions_$rid", variable_get('upload_extensions_default', 'jpg jpeg gif png txt html doc xls pdf ppt pps odt ods odp'));
+        $extensions .= ' '. variable_get("upload_extensions_$rid", variable_get('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'));
       }
 
     }
@@ -771,6 +774,7 @@
     $form['files']['#theme'] = 'upload_form_current';
     $form['files']['#tree'] = TRUE;
     foreach ($node->files as $key => $file) {
+      // Generate valid URL for both existing attachments and preview of new attachments (these have 'upload' in fid)
       $description = file_create_url((strpos($file->fid, 'upload') === FALSE ? $file->filepath : file_create_filename($file->filename, file_create_path())));
       $description = "<small>". check_plain($description) ."</small>";
       $form['files'][$key]['description'] = array('#type' => 'textfield', '#default_value' => (strlen($file->description)) ? $file->description : $file->filename, '#maxlength' => 256, '#description' => $description );
@@ -861,6 +865,7 @@
     if ($width && $height) {
       $result = image_scale($file->filepath, $file->filepath, $width, $height);
       if ($result) {
+        clearstatcache();
         $file->filesize = filesize($file->filepath);
         drupal_set_message(t('The image was resized to fit within the maximum allowed resolution of %resolution pixels.', array('%resolution' => variable_get('upload_max_resolution', 0))));
       }
@@ -874,8 +879,21 @@
  * Menu-callback for JavaScript-based uploads.
  */
 function upload_js() {
-  // We only do the upload.module part of the node validation process.
-  $node = (object)$_POST;
+  if (isset($_POST['vid']) && is_numeric($_POST['vid'])) {
+    // Load the node and check the user is allowed to post attachments to it.
+    $node = node_load(array('vid' => $_POST['vid']));
+    if (!$node || !node_access('update', $node) || !variable_get('upload_'. $node->type, TRUE)) {
+      // Setting this error will cause the form to fail validation.
+      form_set_error('form_token', t('Validation error, please try again. If this error persists, please contact the site administrator.'));
+      $output = theme('status_messages');
+      print drupal_to_js(array('status' => TRUE, 'data' => $output));
+      exit();
+    }
+  }
+  else {
+    // This is a new node.
+    $node = new stdClass();
+  }
 
   // Load existing node files.
   $node->files = upload_load($node);
diff -Naur drupal-5.0/modules/user/user.info drupal-5.23/modules/user/user.info
--- drupal-5.0/modules/user/user.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/user/user.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - required
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/user/user.module drupal-5.23/modules/user/user.module
--- drupal-5.0/modules/user/user.module	2007-01-11 09:52:45.000000000 +0100
+++ drupal-5.23/modules/user/user.module	2009-09-16 21:33:40.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: user.module,v 1.745 2007/01/11 08:52:45 dries Exp $
+// $Id: user.module,v 1.745.2.36 2009/09/16 19:33:40 drumm Exp $
 
 /**
  * @file
@@ -111,6 +111,11 @@
     user_module_invoke('update', $array, $account, $category);
 
     $data = unserialize(db_result(db_query('SELECT data FROM {users} WHERE uid = %d', $account->uid)));
+    // Consider users edited by an administrator as logged in, if they haven't
+    // already, so anonymous users can view the profile (if allowed).
+    if (empty($array['access']) && empty($account->access) && user_access('administer users')) {
+      $array['access'] = time();
+    }
     foreach ($array as $key => $value) {
       if ($key == 'pass' && !empty($value)) {
         $query .= "$key = '%s', ";
@@ -154,6 +159,13 @@
       sess_destroy_uid($account->uid);
     }
 
+    // If the password changed, delete all open sessions and recreate
+    // the current one.
+    if (!empty($array['pass'])) {
+      sess_destroy_uid($account->uid);
+      sess_regenerate();
+    }
+
     // Refresh user object
     $user = user_load(array('uid' => $account->uid));
     user_module_invoke('after_update', $array, $user, $category);
@@ -164,6 +176,11 @@
     if (!isset($array['created'])) {    // Allow 'created' to be set by hook_auth
       $array['created'] = time();
     }
+    // Consider users created by an administrator as already logged in, so
+    // anonymous users can view the profile (if allowed).
+    if (empty($array['access']) && user_access('administer users')) {
+      $array['access'] = time();
+    }
 
     // Note, we wait with saving the data column to prevent module-handled
     // fields from being saved there. We cannot invoke hook_user('insert') here
@@ -295,7 +312,7 @@
       $form_values['picture'] = $file->filepath;
     }
     else {
-      form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist.", array('%directory' => variable_get('user_picture_path', 'pictures'))));
+      form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist or is not writable.", array('%directory' => variable_get('user_picture_path', 'pictures'))));
     }
   }
 }
@@ -358,8 +375,9 @@
   // To reduce the number of SQL queries, we cache the user's permissions
   // in a static variable.
   if (!isset($perm[$account->uid])) {
-    $result = db_query("SELECT DISTINCT(p.perm) FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (%s)", implode(',', array_keys($account->roles)));
-
+    $rids = array_keys($account->roles);
+    $placeholders = implode(',', array_fill(0, count($rids), '%d'));
+    $result = db_query("SELECT DISTINCT(p.perm) FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN ($placeholders)", $rids);
     $perm[$account->uid] = '';
     while ($row = db_fetch_object($result)) {
       $perm[$account->uid] .= "$row->perm, ";
@@ -434,7 +452,7 @@
         $find = array();
         // Replace wildcards with MySQL/PostgreSQL wildcards.
         $keys = preg_replace('!\*+!', '%', $keys);
-        $result = pager_query("SELECT * FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys);
+        $result = pager_query("SELECT name, uid FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys);
         while ($account = db_fetch_object($result)) {
           $find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid, NULL, NULL, TRUE));
         }
@@ -575,13 +593,13 @@
 
       case 3:
         if (user_access('access content')) {
-          // Count users with activity in the past defined period.
+          // Count users active within the defined period.
           $interval = time() - variable_get('user_block_seconds_online', 900);
 
           // Perform database queries to gather online user lists.  We use s.timestamp
-          // rather than u.access because it is much faster is much faster..
+          // rather than u.access because it is much faster.
           $anonymous_count = sess_count($interval);
-          $authenticated_users = db_query('SELECT u.uid, u.name FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
+          $authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
           $authenticated_count = db_num_rows($authenticated_users);
 
           // Format the output with proper grammar.
@@ -649,7 +667,7 @@
   $output .= theme('user_picture', $account);
   foreach ($fields as $category => $items) {
     if (strlen($category) > 0) {
-      $output .= '<h2 class="title">'. $category .'</h2>';
+      $output .= '<h2 class="title">'. check_plain($category) .'</h2>';
     }
     $output .= '<dl>';
     foreach ($items as $item) {
@@ -867,10 +885,8 @@
 
 function user_auth_help_links() {
   $links = array();
-  foreach (module_list() as $module) {
-    if (module_hook($module, 'auth')) {
-      $links[] = l(module_invoke($module, 'info', 'name'), 'user/help', array(), NULL, $module);
-    }
+  foreach (module_implements('auth') as $module) {
+    $links[] = l(module_invoke($module, 'info', 'name'), 'user/help', array(), NULL, $module);
   }
   return $links;
 }
@@ -879,7 +895,7 @@
 
 
 
-function user_login($msg = '') {
+function user_login() {
   global $user;
 
   // If we are already logged on, go to the user page instead.
@@ -888,9 +904,6 @@
   }
 
   // Display login form:
-  if ($msg) {
-    $form['message'] = array('#value' => '<p>'. check_plain($msg) .'</p>');
-  }
   $form['name'] = array('#type' => 'textfield',
     '#title' => t('Username'),
     '#size' => 60,
@@ -919,17 +932,17 @@
   if ($form_values['name']) {
     if (user_is_blocked($form_values['name'])) {
       // blocked in user administration
-      form_set_error('login', t('The username %name has not been activated or is blocked.', array('%name' => $form_values['name'])));
+      form_set_error('name', t('The username %name has not been activated or is blocked.', array('%name' => $form_values['name'])));
     }
     else if (drupal_is_denied('user', $form_values['name'])) {
       // denied by access controls
-      form_set_error('login', t('The name %name is a reserved username.', array('%name' => $form_values['name'])));
+      form_set_error('name', t('The name %name is a reserved username.', array('%name' => $form_values['name'])));
     }
     else if ($form_values['pass']) {
       $user = user_authenticate($form_values['name'], trim($form_values['pass']));
 
       if (!$user->uid) {
-        form_set_error('login', t('Sorry, unrecognized username or password. <a href="@password">Have you forgotten your password?</a>', array('@password' => url('user/password'))));
+        form_set_error('name', t('Sorry, unrecognized username or password. <a href="@password">Have you forgotten your password?</a>', array('@password' => url('user/password'))));
         watchdog('user', t('Login attempt failed for %user.', array('%user' => $form_values['name'])));
       }
     }
@@ -952,9 +965,11 @@
     // Update the user table timestamp noting user has logged in.
     db_query("UPDATE {users} SET login = %d WHERE uid = %d", time(), $user->uid);
 
+    // Regenerate the session ID to prevent against session fixation attacks.
+    sess_regenerate();
+
     user_module_invoke('login', $form_values, $user);
 
-    sess_regenerate();
     return 'user/'. $user->uid;
   }
 }
@@ -964,11 +979,21 @@
 
   // Try to log in the user locally. Don't set $user unless successful.
   if ($account = user_load(array('name' => $name, 'pass' => $pass, 'status' => 1))) {
-    $user = $account;
-    return $user;
+    // Check if the e-mail is denied by an access rule.
+    // Doing this check here saves us a user_load() in user_login_validate()
+    // and introduces less code change for a security fix.
+    if (drupal_is_denied('mail', $account->mail)) {
+      form_set_error('name', t('The name %name is registered using a reserved e-mail address and therefore could not be logged in.', array('%name' => $account->name)));
+      return;
+    }
+    else {
+      $user = $account;
+      return $user;
+    }
   }
 
   // Strip name and server from ID:
+  $fullname = $name;
   if ($server = strrchr($name, '@')) {
     $name = substr($name, 0, strlen($name) - strlen($server));
     $server = substr($server, 1);
@@ -976,10 +1001,10 @@
 
   // When possible, determine corresponding external auth source. Invoke
   // source, and log in user if successful:
-  if ($server && ($result = user_get_authmaps("$name@$server"))) {
+  if ($result = user_get_authmaps($fullname)) {
     if (module_invoke(key($result), 'auth', $name, $pass, $server)) {
-      $user = user_external_load("$name@$server");
-      watchdog('user', t('External load by %user using module %module.', array('%user' => $name .'@'. $server, '%module' => key($result))));
+      $user = user_external_load($fullname);
+      watchdog('user', t('External load by %user using module %module.', array('%user' => $fullname, '%module' => key($result))));
     }
   }
 
@@ -988,17 +1013,18 @@
   else {
     foreach (module_implements('auth') as $module) {
       if (module_invoke($module, 'auth', $name, $pass, $server)) {
-        if ($server) {
-          $name .= '@'. $server;
-        }
-        $user = user_load(array('name' => $name));
-        if (!$user->uid) { // Register this new user.
-          $userinfo = array('name' => $name, 'pass' => user_password(), 'init' => $name, 'status' => 1);
-          if ($server) {
-            $userinfo["authname_$module"] = $name;
-          }
+        $registered_user = user_load(array('name' => $fullname));
+        if (!$registered_user->uid) { // Register this new user.
+          $userinfo = array(
+            'name' => $fullname,
+            'pass' => user_password(), 
+            'init' => $fullname,
+            'status' => 1, 
+            'access' => time(),
+          );
+          $userinfo["authname_$module"] = $fullname;
           $user = user_save('', $userinfo);
-          watchdog('user', t('New external user: %user using module %module.', array('%user' => $name, '%module' => $module)), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
+          watchdog('user', t('New external user: %user using module %module.', array('%user' => $fullname, '%module' => $module)), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
           break;
         }
       }
@@ -1043,6 +1069,13 @@
 
 function user_pass_validate($form_id, $form_values) {
   $name = $form_values['name'];
+
+  // Blocked accounts cannot request a new password,
+  // check provided username and email against access rules.
+  if (drupal_is_denied('user', $name) || drupal_is_denied('mail', $name)) {
+    form_set_error('name', t('%name is not allowed to request a new password.', array('%name' => $name)));
+  }
+
   $account = user_load(array('mail' => $name, 'status' => 1));
   if (!$account) {
     $account = user_load(array('name' => $name, 'status' => 1));
@@ -1062,7 +1095,7 @@
   $from = variable_get('site_mail', ini_get('sendmail_from'));
 
   // Mail one time login URL and instructions.
-  $variables = array('!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'), '!login_url' => user_pass_reset_url($account), '!uri' => $base_url, '!uri_brief' => substr($base_url, strlen('http://')), '!mailto' => $account->mail, '!date' => format_date(time()), '!login_uri' => url('user', NULL, NULL, TRUE), '!edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE));
+  $variables = array('!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'), '!login_url' => user_pass_reset_url($account), '!uri' => $base_url, '!uri_brief' => preg_replace('!^https?://!', '', $base_url), '!mailto' => $account->mail, '!date' => format_date(time()), '!login_uri' => url('user', NULL, NULL, TRUE), '!edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE));
   $subject = _user_mail_text('pass_subject', $variables);
   $body = _user_mail_text('pass_body', $variables);
   $mail_success = drupal_mail('user-pass', $account->mail, $subject, $body, $from);
@@ -1095,6 +1128,11 @@
     $current = time();
     // Some redundant checks for extra security ?
     if ($timestamp < $current && $account = user_load(array('uid' => $uid, 'status' => 1)) ) {
+      // Deny one-time login to blocked accounts.
+      if (drupal_is_denied('user', $account->name) || drupal_is_denied('mail', $account->mail)) {
+        drupal_set_message(t('You have tried to use a one-time login for an account which has been blocked.'), 'error');
+        drupal_goto();
+      }
       // No time out for first time login.
       if ($account->login && $current - $timestamp > $timeout) {
         drupal_set_message(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'));
@@ -1111,6 +1149,8 @@
           $user = $account;
           // And proceed with normal login, going to user page.
           $edit = array();
+          // Regenerate the session ID to prevent against session fixation attacks.
+          sess_regenerate();
           user_module_invoke('login', $edit, $user);
           drupal_set_message(t('You have just used your one-time login link. It is no longer necessary to use this link to login. Please change your password.'));
           drupal_goto('user/'. $user->uid .'/edit');
@@ -1256,7 +1296,9 @@
       $body = _user_mail_text('welcome_body', $variables);
       drupal_mail('user-register-welcome', $mail, $subject, $body, $from);
       user_authenticate($account->name, trim($pass));
-      drupal_goto();
+      $edit = array();
+      user_module_invoke('login', $edit, $account);
+      return '';
     }
     else if ($account->status || $notify) {
       // Create new user account, no administrator approval required.
@@ -1281,7 +1323,7 @@
       drupal_mail('user-register-approval-user', $mail, $subject, $body, $from);
       drupal_mail('user-register-approval-admin', $from, $subject, t("!username has applied for an account.\n\n!edit_uri", $variables), $from);
       drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, your password and further instructions have been sent to your e-mail address.'));
-
+      return '';
     }
   }
 }
@@ -1405,16 +1447,11 @@
     drupal_set_message(t('The account does not exist or has already been deleted.'));
     drupal_goto('admin/user/user');
   }
+
   $edit = $_POST['op'] ? $_POST : (array)$account;
 
   if (arg(2) == 'delete') {
-    if ($edit['confirm']) {
-      user_delete($edit, $account->uid);
-      drupal_goto('admin/user/user');
-    }
-    else {
-      return drupal_get_form('user_confirm_delete', $account->name, $account->uid);
-    }
+    return drupal_get_form('user_confirm_delete', $account->name, $account->uid);
   }
   else if ($_POST['op'] == t('Delete')) {
     if ($_REQUEST['destination']) {
@@ -1439,13 +1476,20 @@
 }
 
 function user_confirm_delete($name, $uid) {
-  return confirm_form(array(),
+  $form['uid'] = array('#type' => 'value', '#value' => $uid);
+  return confirm_form($form,
     t('Are you sure you want to delete the account %name?', array('%name' => $name)),
     'user/'. $uid,
     t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'),
     t('Delete'), t('Cancel'));
 }
 
+function user_confirm_delete_submit($form_id, $form_values) {
+  $account = user_load(array('uid' => $form_values['uid']));
+  user_delete((array) $account, $form_values['uid']);
+  return 'admin/user/user';
+}
+
 /**
  * Delete a user.
  *
@@ -1550,7 +1594,7 @@
       case 'pass_subject':
         return t('Replacement login information for !username at !site', $variables);
       case 'pass_body':
-        return t("!username,\n\nA request to reset the password for your account has been made at !site.\n\nYou may now log in to !uri_brief clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.", $variables);
+        return t("!username,\n\nA request to reset the password for your account has been made at !site.\n\nYou may now log in to !uri_brief by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.", $variables);
     }
   }
 }
@@ -1633,21 +1677,10 @@
  * Menu callback: add an access rule
  */
 function user_admin_access_add($mask = NULL, $type = NULL) {
-  if ($edit = $_POST) {
-    if (!$edit['mask']) {
-      form_set_error('mask', t('You must enter a mask.'));
-    }
-    else {
-      $aid = db_next_id('{access}_aid');
-      db_query("INSERT INTO {access} (aid, mask, type, status) VALUES ('%s', '%s', '%s', %d)", $aid, $edit['mask'], $edit['type'], $edit['status']);
-      drupal_set_message(t('The access rule has been added.'));
-      drupal_goto('admin/user/rules');
-    }
-  }
-  else {
-    $edit['mask'] = $mask;
-    $edit['type'] = $type;
-  }
+  $edit = array();
+  $edit['aid'] = 0;
+  $edit['mask'] = $mask;
+  $edit['type'] = $type;
   return drupal_get_form('user_admin_access_add_form', $edit, t('Add rule'));
 }
 
@@ -1679,23 +1712,16 @@
  * Menu callback: edit an access rule
  */
 function user_admin_access_edit($aid = 0) {
-  if ($edit = $_POST) {
-    if (!$edit['mask']) {
-      form_set_error('mask', t('You must enter a mask.'));
-    }
-    else {
-      db_query("UPDATE {access} SET mask = '%s', type = '%s', status = '%s' WHERE aid = %d", $edit['mask'], $edit['type'], $edit['status'], $aid);
-      drupal_set_message(t('The access rule has been saved.'));
-      drupal_goto('admin/user/rules');
-    }
-  }
-  else {
-    $edit = db_fetch_array(db_query('SELECT aid, type, status, mask FROM {access} WHERE aid = %d', $aid));
-  }
+  $edit = db_fetch_array(db_query('SELECT aid, type, status, mask FROM {access} WHERE aid = %d', $aid));
   return drupal_get_form('user_admin_access_edit_form', $edit, t('Save rule'));
 }
 
 function user_admin_access_form($edit, $submit) {
+  $form = array();
+  $form['aid'] = array(
+    '#type' => 'value',
+    '#value' => $edit['aid'],
+  );
   $form['status'] = array(
     '#type' => 'radios',
     '#title' => t('Access type'),
@@ -1719,11 +1745,27 @@
     '#required' => TRUE,
   );
   $form['submit'] = array('#type' => 'submit', '#value' => $submit);
+  $form['#base'] = 'user_admin_access_form';
 
   return $form;
 }
 
 /**
+ * Submit callback for user_admin_access_form().
+ */
+function user_admin_access_form_submit($form_id, $form_values) {
+  if ($form_values['aid']) {
+    db_query("UPDATE {access} SET mask = '%s', type = '%s', status = '%s' WHERE aid = %d", $form_values['mask'], $form_values['type'], $form_values['status'], $form_values['aid']);
+    drupal_set_message(t('The access rule has been saved.'));
+  }
+  else {
+    db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $form_values['mask'], $form_values['type'], $form_values['status']);
+    drupal_set_message(t('The access rule has been added.'));
+  }
+  return 'admin/user/rules'; 
+}
+
+/**
  * Menu callback: list all access rules
  */
 function user_admin_access() {
@@ -1782,8 +1824,11 @@
   }
 
   // Compile role array:
+  // Add a comma at the end so when searching for a permission, we can
+  // always search for "$perm," to make sure we do not confuse
+  // permissions that are substrings of each other.
   while ($role = db_fetch_object($result)) {
-    $role_permissions[$role->rid] = $role->perm;
+    $role_permissions[$role->rid] = $role->perm .',';
   }
 
   if (is_numeric($rid)) {
@@ -1811,7 +1856,7 @@
         $form['permission'][$perm] = array('#value' => t($perm));
         foreach ($role_names as $rid => $name) {
           // Builds arrays for checked boxes for each role
-          if (strstr($role_permissions[$rid], $perm)) {
+          if (strpos($role_permissions[$rid], $perm .',') !== FALSE) {
             $status[$rid][] = $perm;
           }
         }
@@ -2002,7 +2047,8 @@
 
   $sql = 'SELECT DISTINCT u.uid, u.name, u.status, u.created, u.access FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid '. $filter['join'] .' WHERE u.uid != 0 '. $filter['where'];
   $sql .= tablesort_sql($header);
-  $result = pager_query($sql, 50, 0, NULL, $filter['args']);
+  $query_count = 'SELECT COUNT(DISTINCT u.uid) FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid '. $filter['join'] .' WHERE u.uid != 0 '. $filter['where'];
+  $result = pager_query($sql, 50, 0, $query_count, $filter['args']);
 
   $form['options'] = array(
     '#type' => 'fieldset',
@@ -2356,7 +2402,7 @@
       return '<p>'. t('Drupal allows users to register, login, log out, maintain user profiles, etc. Users of the site may not use their own names to post content until they have signed up for a user account.') .'</p>';
     case 'admin/user/user/create':
     case 'admin/user/user/account/create':
-      return '<p>'. t('This web page allows the administrators to register a new users by hand. Note that you cannot have a user where either the e-mail address or the username match another user in the system.') .'</p>';
+      return '<p>'. t('This web page allows the administrators to register new users by hand. Note that you cannot have a user where either the e-mail address or the username match another user in the system.') .'</p>';
     case 'admin/user/rules':
       return '<p>'. t('Set up username and e-mail address access rules for new <em>and</em> existing accounts (currently logged in accounts will not be logged out). If a username or e-mail address for an account matches any deny rule, but not an allow rule, then the account will not be allowed to be created or to log in. A host rule is effective for every page view, not just registrations.') .'</p>';
     case 'admin/user/access':
@@ -2422,6 +2468,8 @@
 }
 
 function _user_sort($a, $b) {
+  $a = (array)$a + array('weight' => 0, 'title' => '');
+  $b = (array)$b + array('weight' => 0, 'title' => '');
   return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1));
 }
 
@@ -2542,10 +2590,15 @@
                      );
   foreach ($session as $filter) {
     list($type, $value) = $filter;
-    $string = ($i++ ? '<em>and</em> where <strong>%a</strong> is <strong>%b</strong>' : '<strong>%a</strong> is <strong>%b</strong>');
     // Merge an array of arrays into one if necessary.
     $options = $type == 'permission' ? call_user_func_array('array_merge', $filters[$type]['options']) : $filters[$type]['options'];
-    $form['filters']['current'][] = array('#value' => t($string, array('%a' => $filters[$type]['title'] , '%b' => $options[$value])));
+    $params = array('%property' => $filters[$type]['title'] , '%value' => $options[$value]);
+    if ($i++ > 0) {
+      $form['filters']['current'][] = array('#value' => t('<em>and</em> where <strong>%property</strong> is <strong>%value</strong>', $params));
+    }
+    else {
+      $form['filters']['current'][] = array('#value' => t('<strong>%property</strong> is <strong>%value</strong>', $params));
+    }
   }
 
   foreach ($filters as $key => $filter) {
diff -Naur drupal-5.0/modules/watchdog/watchdog.info drupal-5.23/modules/watchdog/watchdog.info
--- drupal-5.0/modules/watchdog/watchdog.info	2007-01-15 13:20:03.000000000 +0100
+++ drupal-5.23/modules/watchdog/watchdog.info	2010-08-11 22:46:30.000000000 +0200
@@ -4,7 +4,8 @@
 package = Core - required
 version = VERSION
 
-; Information added by drupal.org packaging script on 2007-01-15
-version = "5.0"
+; Information added by drupal.org packaging script on 2010-08-11
+version = "5.23"
 project = "drupal"
+datestamp = "1281559590"
 
diff -Naur drupal-5.0/modules/watchdog/watchdog.module drupal-5.23/modules/watchdog/watchdog.module
--- drupal-5.0/modules/watchdog/watchdog.module	2006-12-29 18:22:20.000000000 +0100
+++ drupal-5.23/modules/watchdog/watchdog.module	2007-01-23 20:07:33.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: watchdog.module,v 1.165 2006/12/29 17:22:20 dries Exp $
+// $Id: watchdog.module,v 1.165.2.1 2007/01/23 19:07:33 dries Exp $
 
 /**
  * @file
@@ -95,7 +95,7 @@
     '#options' => $names,
     '#default_value' => $_SESSION['watchdog_overview_filter']
   );
-  $form['submit'] = array('#type' => 'submit', '#value' =>t('Filter'));
+  $form['submit'] = array('#type' => 'submit', '#value' => t('Filter'));
   $form['#redirect'] = FALSE;
 
   return $form;
diff -Naur drupal-5.0/profiles/default/default.profile drupal-5.23/profiles/default/default.profile
--- drupal-5.0/profiles/default/default.profile	2007-01-13 11:21:32.000000000 +0100
+++ drupal-5.23/profiles/default/default.profile	2007-03-26 00:59:33.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: default.profile,v 1.4 2007/01/13 10:21:32 unconed Exp $
+// $Id: default.profile,v 1.4.2.1 2007/03/25 22:59:33 drumm Exp $
 
 /**
  * Return an array of the modules to be enabled when this profile is installed.
@@ -33,6 +33,9 @@
  */
 function default_profile_final() {
   // Insert default user-defined node types into the database.
+  // For a complete list of available node type attributes, refer to the node
+  // type API documentation at:
+  // http://api.drupal.org/api/HEAD/function/hook_node_info
   $types = array(
     array(
       'type' => 'page',
diff -Naur drupal-5.0/robots.txt drupal-5.23/robots.txt
--- drupal-5.0/robots.txt	2007-01-08 13:02:18.000000000 +0100
+++ drupal-5.23/robots.txt	2008-12-10 21:24:38.000000000 +0100
@@ -1,4 +1,4 @@
-# $Id: robots.txt,v 1.7 2007/01/08 12:02:18 dries Exp $
+# $Id: robots.txt,v 1.7.2.3 2008/12/10 20:24:38 drumm Exp $
 #
 # robots.txt
 #
@@ -20,29 +20,27 @@
 User-agent: *
 Crawl-delay: 10
 # Directories
-Disallow: /database/
 Disallow: /includes/
 Disallow: /misc/
 Disallow: /modules/
+Disallow: /profiles/
+Disallow: /scripts/
 Disallow: /sites/
 Disallow: /themes/
-Disallow: /scripts/
-Disallow: /updates/
-Disallow: /profiles/
 # Files
-Disallow: /xmlrpc.php
+Disallow: /CHANGELOG.txt
 Disallow: /cron.php
-Disallow: /update.php
-Disallow: /install.php
 Disallow: /INSTALL.mysql.txt
 Disallow: /INSTALL.pgsql.txt
-Disallow: /CHANGELOG.txt
-Disallow: /MAINTAINERS.txt
+Disallow: /install.php
+Disallow: /INSTALL.txt
 Disallow: /LICENSE.txt
+Disallow: /MAINTAINERS.txt
+Disallow: /update.php
 Disallow: /UPGRADE.txt
+Disallow: /xmlrpc.php
 # Paths (clean URLs)
 Disallow: /admin/
-Disallow: /aggregator/
 Disallow: /comment/reply/
 Disallow: /contact/
 Disallow: /logout/
@@ -53,7 +51,6 @@
 Disallow: /user/login/
 # Paths (no clean URLs)
 Disallow: /?q=admin/
-Disallow: /?q=aggregator/
 Disallow: /?q=comment/reply/
 Disallow: /?q=contact/
 Disallow: /?q=logout/
diff -Naur drupal-5.0/sites/default/settings.php drupal-5.23/sites/default/settings.php
--- drupal-5.0/sites/default/settings.php	2007-01-14 03:05:15.000000000 +0100
+++ drupal-5.23/sites/default/settings.php	2009-06-16 20:29:52.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: settings.php,v 1.39 2007/01/14 02:05:15 unconed Exp $
+// $Id: settings.php,v 1.39.2.4 2009/06/16 18:29:52 drumm Exp $
 
 /**
  * @file
@@ -132,22 +132,20 @@
 ini_set('session.cookie_lifetime',  2000000);
 ini_set('session.gc_maxlifetime',   200000);
 ini_set('session.save_handler',     'user');
+ini_set('session.use_cookies',      1);
 ini_set('session.use_only_cookies', 1);
 ini_set('session.use_trans_sid',    0);
 ini_set('url_rewriter.tags',        '');
 
 /**
- * We try to set the correct cookie domain. If you are experiencing problems
- * try commenting out the code below or specifying the cookie domain by hand.
+ * Drupal automatically generates a unique session cookie name for each site
+ * based on on its full domain name. If you have multiple domains pointing at
+ * the same Drupal site, you can either redirect them all to a single domain
+ * (see comment in .htaccess), or uncomment the line below and specify their
+ * shared base domain. Doing so assures that users remain logged in as they
+ * cross between your various domains.
  */
-if (isset($_SERVER['HTTP_HOST'])) {
-  $domain = '.'. preg_replace('`^www.`', '', $_SERVER['HTTP_HOST']);
-  // Per RFC 2109, cookie domains must contain at least one dot other than the
-  // first. For hosts such as 'localhost', we don't set a cookie domain.
-  if (count(explode('.', $domain)) > 2) {
-    ini_set('session.cookie_domain', $domain);
-  }
-}
+# $cookie_domain = 'example.com';
 
 /**
  * Variable overrides:
diff -Naur drupal-5.0/themes/bluemarine/page.tpl.php drupal-5.23/themes/bluemarine/page.tpl.php
--- drupal-5.0/themes/bluemarine/page.tpl.php	2006-08-30 09:37:13.000000000 +0200
+++ drupal-5.23/themes/bluemarine/page.tpl.php	2009-04-30 02:13:49.000000000 +0200
@@ -2,8 +2,8 @@
 <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language ?>" xml:lang="<?php print $language ?>">
 
 <head>
-  <title><?php print $head_title ?></title>
   <?php print $head ?>
+  <title><?php print $head_title ?></title>
   <?php print $styles ?>
   <?php print $scripts ?>
   <script type="text/javascript"><?php /* Needed to avoid Flash of Unstyle Content in IE */ ?> </script>
diff -Naur drupal-5.0/themes/chameleon/chameleon.theme drupal-5.23/themes/chameleon/chameleon.theme
--- drupal-5.0/themes/chameleon/chameleon.theme	2006-11-29 07:36:12.000000000 +0100
+++ drupal-5.23/themes/chameleon/chameleon.theme	2009-04-30 02:13:49.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: chameleon.theme,v 1.56 2006/11/29 06:36:12 drumm Exp $
+// $Id: chameleon.theme,v 1.56.2.3 2009/04/30 00:13:49 drumm Exp $
 
 /**
  * @file
@@ -39,8 +39,8 @@
   $output  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
   $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"$language\" xml:lang=\"$language\">\n";
   $output .= "<head>\n";
-  $output .= " <title>". ($title ? strip_tags($title) ." | ". variable_get("site_name", "Drupal") : variable_get("site_name", "Drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";
   $output .= drupal_get_html_head();
+  $output .= " <title>". ($title ? strip_tags($title) ." | ". variable_get("site_name", "Drupal") : variable_get("site_name", "Drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";
   $output .= drupal_get_css();
   $output .= drupal_get_js();
   $output .= "</head>";
@@ -138,7 +138,15 @@
 
   $output .= " </div>\n";
 
-  $submitted['node_submitted'] = theme_get_setting("toggle_node_info_$node->type") ? array('#title' => t("By !author at @date", array('!author' => theme('username', $node), '@date' => format_date($node->created, 'small')))) : array();
+  if (theme_get_setting("toggle_node_info_$node->type")) {
+    $submitted['node_submitted'] = array(
+      'title' => t("By !author at @date", array('!author' => theme('username', $node), '@date' => format_date($node->created, 'small'))),
+      'html' => TRUE,
+    );
+  }
+  else {
+    $submitted['node_submitted'] = array();
+  }
 
   $terms = array();
   if (module_exists('taxonomy')) {
@@ -159,7 +167,10 @@
 }
 
 function chameleon_comment($comment, $links = "") {
-  $submitted['comment_submitted'] = array('#title' => t('By !author at @date', array('!author' => theme('username', $comment), '@date' => format_date($comment->timestamp, 'small'))));
+  $submitted['comment_submitted'] = array(
+    'title' => t('By !author at @date', array('!author' => theme('username', $comment), '@date' => format_date($comment->timestamp, 'small'))),
+    'html' => TRUE,
+  );
 
   $output  = "<div class=\"comment". ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') ."\">\n";
   $output .= " <h3 class=\"title\">". l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") ."</h3>\n";
@@ -175,5 +186,3 @@
     return '<div class="help">'. $help .'</div><hr />';
   }
 }
-
-?>
diff -Naur drupal-5.0/themes/chameleon/common.css drupal-5.23/themes/chameleon/common.css
--- drupal-5.0/themes/chameleon/common.css	2006-08-30 09:37:14.000000000 +0200
+++ drupal-5.23/themes/chameleon/common.css	2007-09-13 20:59:59.000000000 +0200
@@ -1,4 +1,4 @@
-/* $Id: common.css,v 1.11 2006/08/30 07:37:14 drumm Exp $ */
+/* $Id: common.css,v 1.11.2.1 2007/09/13 18:59:59 drumm Exp $ */
 
 /*
 ** HTML elements
@@ -82,6 +82,7 @@
  font-size: 0.8em;
  padding-top: 2em;
  text-align: center;
+ clear: both;
 }
 
 /*
diff -Naur drupal-5.0/themes/engines/phptemplate/phptemplate.engine drupal-5.23/themes/engines/phptemplate/phptemplate.engine
--- drupal-5.0/themes/engines/phptemplate/phptemplate.engine	2006-12-30 21:59:11.000000000 +0100
+++ drupal-5.23/themes/engines/phptemplate/phptemplate.engine	2009-05-13 18:36:22.000000000 +0200
@@ -1,5 +1,5 @@
 <?php
-// $Id: phptemplate.engine,v 1.54 2006/12/30 20:59:11 drumm Exp $
+// $Id: phptemplate.engine,v 1.54.2.9 2009/05/13 16:36:22 drumm Exp $
 
 /**
  * @file
@@ -113,7 +113,9 @@
       // This pre-loading is necessary because phptemplate uses variable names different from
       // the region names, e.g., 'sidebar_left' instead of 'left'.
       if (!in_array($region, array('left', 'right', 'footer'))) {
-        isset($variables[$region]) ? $variables[$region] .= theme('blocks', $region) : $variables[$region] = theme('blocks', $region);
+        $normal_blocks = (isset($variables['regions'])) ? $variables['regions'][$region] : theme('blocks', $region);
+
+        isset($variables[$region]) ? $variables[$region] .= $normal_blocks : $variables[$region] = $normal_blocks;
       }
     }
   }
@@ -148,6 +150,9 @@
  * current path. If none are found, the default page.tpl.php is used.
  */
 function phptemplate_page($content, $show_blocks = TRUE) {
+  global $theme;
+  $regions = array_keys(system_region_list($theme));
+  $variables = array('regions'=>array());
 
   /* Set title and breadcrumb to declared values */
   if (drupal_is_front_page()) {
@@ -159,31 +164,41 @@
     drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
   }
 
-  /**
-  * Populate sidebars.
-  */
+  // Populate sidebars
+  $layout = 'none';
   if ($show_blocks) {
     global $sidebar_indicator;
-    /**
-     * Sidebar_indicator tells the block counting code to count sidebars separately.
-     */
-    $sidebar_indicator = 'left';
-    $sidebar_left = theme('blocks', 'left');
+
+    // Load blocks early for adding header info
+    foreach ($regions as $region) {
+      // Sidebar_indicator tells the block counting code
+      // to count sidebars separately.
+      if ($region == 'left' || $region == 'right') {
+        $sidebar_indicator = $region;
+      }
+      else {
+        $sidebar_indicator = NULL;
+      }
+      $variables['regions'][$region] = theme('blocks', $region);
+    }
+    $sidebar_indicator = NULL;
+
+    $sidebar_left = $variables['regions']['left'];
     if ($sidebar_left != '') {
       $layout = 'left';
     }
 
-    $sidebar_indicator = 'right';
-    $sidebar_right = theme('blocks', 'right');
+    $sidebar_right = $variables['regions']['right'];
     if ($sidebar_right != '') {
       $layout = ($layout == 'left') ? 'both' : 'right';
     }
-    $sidebar_indicator = NULL;
   }
   else {
-   $layout = 'none';
+    // Add empty strings as default
+    foreach($regions as $region) {
+      $variables['regions'][$region] = '';
+    }
   }
-
   // Construct page title
   if (drupal_get_title()) {
     $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal'));
@@ -195,13 +210,13 @@
     }
   }
 
-  $variables = array(
+  $variables = array_merge($variables, array(
     'base_path'           => base_path(),
     'breadcrumb'          => theme('breadcrumb', drupal_get_breadcrumb()),
     'closure'             => theme('closure'),
     'content'             => $content,
     'feed_icons'          => drupal_get_feeds(),
-    'footer_message'      => filter_xss_admin(variable_get('site_footer', FALSE)) . "\n" . theme('blocks', 'footer'),
+    'footer_message'      => filter_xss_admin(variable_get('site_footer', FALSE)) . "\n" . $variables['regions']['footer'],
     'head'                => drupal_get_html_head(),
     'head_title'          => implode(' | ', $head_title),
     'help'                => theme('help'),
@@ -222,7 +237,7 @@
     'scripts'             => drupal_get_js(),
     'tabs'                => theme('menu_local_tasks'),
     'title'               => drupal_get_title()
-  );
+  ));
 
   if ((arg(0) == 'node') && is_numeric(arg(1))) {
     $variables['node'] = node_load(arg(1));
@@ -242,6 +257,7 @@
   $suggestion = 'page';
   $suggestions = array($suggestion);
   while ($arg = arg($i++)) {
+    $arg = str_replace(array("/", "\\", "\0"), '', $arg);
     $suggestions[] = $suggestion . '-' . $arg;
     if (!is_numeric($arg)) {
       $suggestion .= '-' . $arg;
@@ -254,7 +270,7 @@
   return _phptemplate_callback('page', $variables, $suggestions);
 }
 
-/*
+/**
  * Prepare the values passed to the theme_node function to be passed
  * into a pluggable template engine.
  */
@@ -356,7 +372,10 @@
  * @param $variables
  *   A sequential array of variables passed to the theme function.
  * @param $suggestions
- *   An array of suggested template files to use.
+ *   An array of suggested template files to use. This may include a path when
+ *   the suggested template is contained within a sub-directory of the theme.
+ *   They are set from _phptemplate_variables() or the theming hook invoking
+ *   _phptemplate_callback().
  */
 function _phptemplate_default($hook, $variables, $suggestions = array(), $extension = '.tpl.php') {
   global $theme_engine;
@@ -399,5 +418,3 @@
   ob_end_clean();                  // End buffering and discard
   return $contents;                // Return the contents
 }
-
-?>
diff -Naur drupal-5.0/themes/garland/fix-ie.css drupal-5.23/themes/garland/fix-ie.css
--- drupal-5.0/themes/garland/fix-ie.css	2007-01-10 09:48:45.000000000 +0100
+++ drupal-5.23/themes/garland/fix-ie.css	2007-04-18 05:38:59.000000000 +0200
@@ -1,3 +1,5 @@
+/* $Id: fix-ie.css,v 1.3.2.1 2007/04/18 03:38:59 drumm Exp $ */
+
 /**
  * Themetastic, for Drupal 5.0
  * Stefan Nagtegaal, iStyledThis [dot] nl
diff -Naur drupal-5.0/themes/garland/minnelli/style.css drupal-5.23/themes/garland/minnelli/style.css
--- drupal-5.0/themes/garland/minnelli/style.css	2007-01-04 04:27:07.000000000 +0100
+++ drupal-5.23/themes/garland/minnelli/style.css	2007-04-18 05:38:59.000000000 +0200
@@ -1,3 +1,5 @@
+/* $Id: style.css,v 1.3.2.1 2007/04/18 03:38:59 drumm Exp $ */
+
 /**
  * Minnelli, for Drupal 5.0
  * Stefan Nagtegaal, iStyledThis [dot] nl
diff -Naur drupal-5.0/themes/garland/page.tpl.php drupal-5.23/themes/garland/page.tpl.php
--- drupal-5.0/themes/garland/page.tpl.php	2006-12-14 01:37:00.000000000 +0100
+++ drupal-5.23/themes/garland/page.tpl.php	2009-04-30 02:13:49.000000000 +0200
@@ -2,8 +2,8 @@
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language ?>" lang="<?php print $language ?>">
   <head>
-    <title><?php print $head_title ?></title>
     <?php print $head ?>
+    <title><?php print $head_title ?></title>
     <?php print $styles ?>
     <?php print $scripts ?>
     <style type="text/css" media="print">@import "<?php print base_path() . path_to_theme() ?>/print.css";</style>
diff -Naur drupal-5.0/themes/garland/print.css drupal-5.23/themes/garland/print.css
--- drupal-5.0/themes/garland/print.css	2006-12-14 01:37:00.000000000 +0100
+++ drupal-5.23/themes/garland/print.css	2007-04-18 05:38:59.000000000 +0200
@@ -1,3 +1,5 @@
+/* $Id: print.css,v 1.1.2.1 2007/04/18 03:38:59 drumm Exp $ */
+
 /**
  * Themetastic, for Drupal 5.0
  * Stefan Nagtegaal, iStyledThis [dot] nl
diff -Naur drupal-5.0/themes/garland/style.css drupal-5.23/themes/garland/style.css
--- drupal-5.0/themes/garland/style.css	2007-01-10 09:24:02.000000000 +0100
+++ drupal-5.23/themes/garland/style.css	2009-09-16 06:38:12.000000000 +0200
@@ -1,3 +1,5 @@
+/* $Id: style.css,v 1.14.2.5 2009/09/16 04:38:12 drumm Exp $ */
+
 /**
  * Garland, for Drupal 5.0
  * Stefan Nagtegaal, iStyledThis [dot] nl
@@ -289,6 +291,11 @@
   margin-bottom: 0;
 }
 
+/* Avoid displaying content of script tags */
+#header-region script {
+  display: none;
+}
+
 #header-region p, #header-region img {
   margin-top: 0.5em;
 }
@@ -342,7 +349,7 @@
 body.sidebars {
   min-width: 980px;
 }
-/* With 2 columsn, require a minimum width of 800px. */
+/* With 2 columns, require a minimum width of 800px. */
 body.sidebar-left, body.sidebar-right {
   min-width: 780px;
 }
@@ -599,6 +606,7 @@
   text-decoration: none;
   position: relative;
   top: -1px;
+  display: inline-block;
 }
 ul.primary li.active a, ul.primary li.active a:link, ul.primary li.active a:visited, ul.primary li a:hover,
 ul.secondary li.active a, ul.secondary li.active a:link, ul.secondary li.active a:visited, ul.secondary li a:hover {
@@ -785,6 +793,11 @@
   background: #fff url(images/gradient-inner.png) repeat-x 0 0;
 }
 
+fieldset legend {
+  /* Fix disappearing legend in FFox */
+  display: block;
+}
+
 html.js fieldset.collapsed {
   background: transparent;
   padding-top: 0;
diff -Naur drupal-5.0/themes/garland/template.php drupal-5.23/themes/garland/template.php
--- drupal-5.0/themes/garland/template.php	2006-12-12 22:32:18.000000000 +0100
+++ drupal-5.23/themes/garland/template.php	2007-04-18 05:38:59.000000000 +0200
@@ -1,4 +1,6 @@
 <?php
+// $Id: template.php,v 1.4.2.1 2007/04/18 03:38:59 drumm Exp $
+
 /**
  * Sets the body-tag class attribute.
  *
diff -Naur drupal-5.0/themes/pushbutton/page.tpl.php drupal-5.23/themes/pushbutton/page.tpl.php
--- drupal-5.0/themes/pushbutton/page.tpl.php	2006-08-30 09:37:14.000000000 +0200
+++ drupal-5.23/themes/pushbutton/page.tpl.php	2009-04-30 02:13:49.000000000 +0200
@@ -1,9 +1,9 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language ?>" xml:lang="<?php print $language ?>">
 <head>
-  <title><?php print $head_title ?></title>
   <meta http-equiv="Content-Style-Type" content="text/css" />
   <?php print $head ?>
+  <title><?php print $head_title ?></title>
   <?php print $styles ?>
   <?php print $scripts ?>
 </head>
diff -Naur drupal-5.0/update.php drupal-5.23/update.php
--- drupal-5.0/update.php	2006-12-25 22:22:03.000000000 +0100
+++ drupal-5.23/update.php	2008-12-10 23:21:27.000000000 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: update.php,v 1.211 2006/12/25 21:22:03 drumm Exp $
+// $Id: update.php,v 1.211.2.3 2008/12/10 22:21:27 drumm Exp $
 
 /**
  * @file
@@ -391,7 +391,9 @@
   }
 
   // Keep track of total number of updates
-  $_SESSION['update_total'] = count($_SESSION['update_remaining']);
+  if (isset($_SESSION['update_remaining'])) {
+    $_SESSION['update_total'] = count($_SESSION['update_remaining']);
+  }
 
   if ($_POST['has_js']) {
     return update_progress_page();
@@ -510,8 +512,8 @@
 function update_finished_page($success) {
   drupal_set_title('Drupal database update');
   // NOTE: we can't use l() here because the URL would point to 'update.php?q=admin'.
-  $links[] = '<a href="'. base_path() .'">main page</a>';
-  $links[] = '<a href="'. base_path() .'?q=admin">administration pages</a>';
+  $links[] = '<a href="'. base_path() .'">Main page</a>';
+  $links[] = '<a href="'. base_path() .'?q=admin">Administration pages</a>';
 
   // Report end result
   if ($success) {
@@ -529,7 +531,7 @@
   $output .= theme('item_list', $links);
 
   // Output a list of queries executed
-  if ($_SESSION['update_results']) {
+  if (!empty($_SESSION['update_results'])) {
     $output .= '<div id="update-results">';
     $output .= '<h2>The following queries were executed</h2>';
     foreach ($_SESSION['update_results'] as $module => $updates) {
@@ -560,10 +562,11 @@
 
 function update_info_page() {
   drupal_set_title('Drupal database update');
+  $link = 'update.php?op=selection&token='. drupal_get_token('update');
   $output = "<ol>\n";
   $output .= "<li>Use this script to <strong>upgrade an existing Drupal installation</strong>. You don't need this script when installing Drupal from scratch.</li>";
   $output .= "<li>Before doing anything, backup your database. This process will change your database and its values, and some things might get lost.</li>\n";
-  $output .= "<li>Update your Drupal sources, check the notes below and <a href=\"update.php?op=selection\">run the database upgrade script</a>. Don't upgrade your database twice as it may cause problems.</li>\n";
+  $output .= "<li>Update your Drupal sources, check the notes below and <a href=\"$link\">run the database upgrade script</a>. Don't upgrade your database twice as it may cause problems.</li>\n";
   $output .= "<li>Go through the various administration pages to change the existing and new settings to your liking.</li>\n";
   $output .= "</ol>";
   $output .= '<p>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>';
@@ -791,10 +794,6 @@
 
   $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
   switch ($op) {
-    case 'Update':
-      $output = update_update_page();
-      break;
-
     case 'finished':
       $output = update_finished_page(TRUE);
       break;
@@ -811,10 +810,18 @@
       $output = update_progress_page_nojs();
       break;
 
+    case 'Update':
+      if ($_GET['token'] == drupal_get_token('update')) {
+        $output = update_update_page();
+        break;
+      }
+      // If the token did not match we just display the default page.
     case 'selection':
-      $output = update_selection_page();
-      break;
-
+      if ($_GET['token'] == drupal_get_token('update')) {
+        $output = update_selection_page();
+        break;
+      }
+      // If the token did not match we just display the default page.
     default:
       $output = update_info_page();
       break;

