--- drupal-4.6.5/update.php 2005-12-20 17:30:16.000000000 +0200 +++ drupal-4.6.5/update.php 2005-12-20 18:26:23.000000000 +0200 @@ -206,6 +206,65 @@ print update_page_footer(); } +if (php_sapi_name() == 'cli') { + $_SERVER['REMOTE_ADDR'] = '0.0.0.0'; + + include_once "includes/bootstrap.inc"; + include_once "includes/common.inc"; + + function get_update_index($date) { + global $sql_updates; + + $hash = array_flip(array_keys($sql_updates)); + if (!isset($hash[$date])) { + return null; + } + return $hash[$date]; + } + + if (isset($argv[2])) { + # user specified the date + $start = get_update_index($argv[2]); + if (is_null($start)) { + die("Can't find requested update: $argv[2]\n"); + } + + } else { + # lookup update date from database + $date = variable_get("update_start", 0); + + $start = get_update_index($date); + if (is_null($start)) { + die("No updates available\n"); + } + # but we need next entry instead + $start++; + } + + # "0" reserved for "All" + $start++; + + $_POST['op'] = $argv[1]; + $_POST['edit'] = array( + 'start' => $start, + ); + + ob_start(); + update_page(); + $page = ob_get_contents(); + ob_end_clean(); + + # primitive html renderer ;) + if (preg_match('#
(.+)#s', $page, $m)) { + $page = $m[1]; + $page = preg_replace('#