diff -N -c -r 3.0.4.orig/calendar.php 3.0.4.1/calendar.php
*** 3.0.4.orig/calendar.php	Wed Dec 31 18:00:00 1969
--- 3.0.4.1/calendar.php	Mon Mar 26 13:35:39 2007
***************
*** 0 ****
--- 1,41 ----
+ <?php
+ $calendar = '
+ <script type="text/javascript">
+ function isDisabled(date, y, m, d) {
+   var today = new Date();
+   return (today.getTime() - date.getTime()) < -1 * Date.DAY;
+ }
+ Calendar.setup({
+   inputField     : "cs",
+   ifFormat       : "%b %d %Y %H:%M",
+   showsTime      : true,
+   step           : 1,
+   weekNumbers    : false,
+   dateStatusFunc : isDisabled
+ });
+ </script>
+ <script type="text/javascript">
+ Calendar.setup({
+   inputField     : "ce",
+   ifFormat       : "%b %d %Y %H:%M",
+   showsTime      : true,
+   step           : 1,
+   weekNumbers    : false,
+   dateStatusFunc : isDisabled
+ });
+ </script>
+ ';
+ $calendar_head = '
+ <link rel="stylesheet" type="text/css" media="all" href="jscalendar-1.0/calendar-system.css" title="calendar-system" />
+ <script type="text/javascript" src="jscalendar-1.0/calendar.js"></script>
+ <script type="text/javascript" src="jscalendar-1.0/lang/calendar-en.js"></script>
+ <script type="text/javascript" src="jscalendar-1.0/calendar-setup.js"></script>
+ <script>
+ function myclear() {
+   document.getElementById("cs").value = "";
+   document.getElementById("ce").value = "";
+   document.ganglia_form.submit();
+ }
+ </script>
+ ';
+ ?>
diff -N -c -r 3.0.4.orig/cluster_view.php 3.0.4.1/cluster_view.php
*** 3.0.4.orig/cluster_view.php	Mon Dec 25 04:02:38 2006
--- 3.0.4.1/cluster_view.php	Mon Jul 16 10:52:51 2007
***************
*** 192,200 ****
                    $graphargs = (isset($reports[$metricname]) and
                                  $reports[$metricname]) ?
                          "g=$metricname&amp;" : "m=$metricname&amp;";
!                   $graphargs .= "z=small&amp;c=$cluster_url&amp;h=$host_url"
                       ."&amp;l=$load_color&amp;v=$val[VAL]&amp;x=$max&amp;n=$min"
                       ."&amp;r=$range&amp;st=$cluster[LOCALTIME]";
                 }
           }
  
--- 192,205 ----
                    $graphargs = (isset($reports[$metricname]) and
                                  $reports[$metricname]) ?
                          "g=$metricname&amp;" : "m=$metricname&amp;";
!                   $graphadd = "z=small&amp;c=$cluster_url&amp;h=$host_url"
                       ."&amp;l=$load_color&amp;v=$val[VAL]&amp;x=$max&amp;n=$min"
                       ."&amp;r=$range&amp;st=$cluster[LOCALTIME]";
+ 		  if ($cs)
+ 		    $graphadd .= "&amp;cs=$cs";
+ 		  if ($ce)
+ 		    $graphadd .= "&amp;ce=$ce";
+ 		  $graphargs .= $graphadd;
                 }
           }
  
diff -N -c -r 3.0.4.orig/get_context.php 3.0.4.1/get_context.php
*** 3.0.4.orig/get_context.php	Mon Dec 25 04:02:38 2006
--- 3.0.4.1/get_context.php	Mon Jul 16 11:03:29 2007
***************
*** 34,39 ****
--- 34,44 ----
  # A red vertical line for various events. Value specifies the event time.
  $jobstart = isset($_GET["js"]) ?
  	escapeshellcmd($_GET["js"]) : NULL;
+ # custom start and end
+ $cs = isset($_GET["cs"]) ?
+ 	escapeshellcmd($_GET["cs"]) : NULL;
+ $ce = isset($_GET["ce"]) ?
+ 	escapeshellcmd($_GET["ce"]) : NULL;
  # The direction we are travelling in the grid tree
  $gridwalk = isset($_GET["gw"]) ?
  	escapeshellcmd($_GET["gw"]) : NULL;
***************
*** 109,114 ****
--- 114,121 ----
       }
     default: $start = -3600;
  }
+ if ($cs or $ce)
+      $range = "custom";
  
  if (!$metricname)
        $metricname = "$default_metric";
diff -N -c -r 3.0.4.orig/graph.php 3.0.4.1/graph.php
*** 3.0.4.orig/graph.php	Mon Dec 25 04:02:38 2006
--- 3.0.4.1/graph.php	Mon Jul 16 11:57:36 2007
***************
*** 302,311 ****
  if ($range=="month")
     $end = floor($end / 672) * 672;
  
  #
  # Generate the rrdtool graph command.
  #
! $command = RRDTOOL . " graph - --start $start --end $end ".
     "--width $width --height $height $upper_limit $lower_limit ".
     "--title '$title' $vertical_label $extras $background ".
     $series;
--- 302,316 ----
  if ($range=="month")
     $end = floor($end / 672) * 672;
  
+ if ($cs)
+     $start = $cs;
+ if ($ce)
+     $end = $ce;
+ 
  #
  # Generate the rrdtool graph command.
  #
! $command = RRDTOOL . " graph - --start '$start' --end '$end' ".
     "--width $width --height $height $upper_limit $lower_limit ".
     "--title '$title' $vertical_label $extras $background ".
     $series;
diff -N -c -r 3.0.4.orig/header.php 3.0.4.1/header.php
*** 3.0.4.orig/header.php	Mon Dec 25 04:02:38 2006
--- 3.0.4.1/header.php	Mon Jul 16 11:44:30 2007
***************
*** 5,10 ****
--- 5,11 ----
  include_once "auth.php";
  checkcontrol();
  checkprivate();
+ include_once "calendar.php";
  
  # RFM - These definitions are here to eliminate "undefined variable"
  # error maessages in ssl_error_log.
***************
*** 97,102 ****
--- 98,107 ----
  $get_metric_string = "m=$metric&amp;r=$range&amp;s=$sort_url&amp;hc=$hostcols";
  if ($jobrange and $jobstart)
          $get_metric_string .= "&amp;jr=$jobrange&amp;js=$jobstart";
+ if ($cs)
+     $get_metric_string .= "&amp;cs=" . rawurlencode($cs);
+ if ($ce)
+     $get_metric_string .= "&amp;ce=" . rawurlencode($ce);
  
  # Set the Alternate view link.
  $cluster_url=rawurlencode($clustername);
***************
*** 248,256 ****
     $context_ranges[]="year";
     if ($jobrange)
        $context_ranges[]="job";
  
     $range_menu = "<B>Last</B>&nbsp;&nbsp;"
!       ."<SELECT NAME=\"r\" OnChange=\"ganglia_form.submit();\">\n";
     foreach ($context_ranges as $v) {
        $url=rawurlencode($v);
        $range_menu .= "<OPTION VALUE=\"$url\" ";
--- 253,263 ----
     $context_ranges[]="year";
     if ($jobrange)
        $context_ranges[]="job";
+    if ($cs or $ce)
+       $context_ranges[]="custom";
  
     $range_menu = "<B>Last</B>&nbsp;&nbsp;"
!       ."<SELECT NAME=\"r\" OnChange=\"myclear();\">\n";
     foreach ($context_ranges as $v) {
        $url=rawurlencode($v);
        $range_menu .= "<OPTION VALUE=\"$url\" ";
***************
*** 328,333 ****
--- 335,359 ----
        # Assign template variable in cluster view.
     }
  
+ 
+ 
+ {
+     $examples = "Feb 27 2007 00:00, 2/27/2007, 27.2.2007, now -1 week,"
+ 	. " -2 days, start + 1 hour, etc.";
+     $custom_time .= "<br>or from <INPUT TYPE=\"TEXT\" TITLE=\"$examples\" NAME=\"cs\" ID=\"cs\"";
+     if ($cs)
+ 	$custom_time .= " value=\"$cs\"";
+     $custom_time .= "> to <INPUT TYPE=\"TEXT\" TITLE=\"$examples\" NAME=\"ce\" ID=\"ce\"";
+     if ($ce)
+ 	$custom_time .= " value=\"$ce\"";
+     $custom_time .= "><input type=\"submit\" value=\"Go\">\n";
+     $custom_time .= $calendar;
+     $tpl->assign("custom_time", $custom_time);
+ 
+     $tpl->assign("custom_time_head", $calendar_head);
+ }
+ 
+ 
  # Make sure that no data is cached..
  header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    # Date in the past
  header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); # always modified
diff -N -c -r 3.0.4.orig/host_view.php 3.0.4.1/host_view.php
*** 3.0.4.orig/host_view.php	Mon Dec 25 04:02:38 2006
--- 3.0.4.1/host_view.php	Mon Jul 16 10:45:04 2007
***************
*** 52,57 ****
--- 52,61 ----
               $graphargs = "c=$cluster_url&amp;h=$hostname&amp;v=$v[VAL]"
                 ."&amp;m=$name&amp;r=$range&amp;z=medium&amp;jr=$jobrange"
                 ."&amp;js=$jobstart&amp;st=$cluster[LOCALTIME]";
+ 	     if ($cs)
+ 	       $graphargs .= "&amp;cs=$cs";
+ 	     if ($ce)
+ 	       $graphargs .= "&amp;ce=$ce";
               # Adding units to graph 2003 by Jason Smith <smithj4@bnl.gov>.
               if ($v['UNITS']) {
                  $encodeUnits = rawurlencode($v['UNITS']);
diff -N -c -r 3.0.4.orig/meta_view.php 3.0.4.1/meta_view.php
*** 3.0.4.orig/meta_view.php	Mon Dec 25 04:02:38 2006
--- 3.0.4.1/meta_view.php	Mon Jul 16 11:50:05 2007
***************
*** 73,79 ****
                    $name = "$source $meta_designator";
                    $graph_url = "G=$sourceurl&amp;$get_metric_string&amp;st=$localtime";
                    $authority = $grid[$source]['AUTHORITY'];
!                   $url = "$authority?gw=fwd&amp;gs=$gridstack_url";
                 }
              $alt_url = "<a href=\"./?t=yes&amp;$get_metric_string\">(tree view)</a>";
              $class = "grid";
--- 73,79 ----
                    $name = "$source $meta_designator";
                    $graph_url = "G=$sourceurl&amp;$get_metric_string&amp;st=$localtime";
                    $authority = $grid[$source]['AUTHORITY'];
!                   $url = "$authority?gw=fwd&amp;gs=$gridstack_url&amp;$get_metric_string";
                 }
              $alt_url = "<a href=\"./?t=yes&amp;$get_metric_string\">(tree view)</a>";
              $class = "grid";
diff -N -c -r 3.0.4.orig/templates/default/header.tpl 3.0.4.1/templates/default/header.tpl
*** 3.0.4.orig/templates/default/header.tpl	Mon Dec 25 04:02:38 2006
--- 3.0.4.1/templates/default/header.tpl	Mon Jul 16 10:46:40 2007
***************
*** 5,10 ****
--- 5,11 ----
  <META http-equiv="Content-type" content="text/html; charset=utf-8">
  <META http-equiv="refresh" content="{refresh}{redirect}" >
  <LINK rel="stylesheet" href="./styles.css" type="text/css">
+ {custom_time_head}
  </HEAD>
  <BODY BGCOLOR="#FFFFFF">
  
***************
*** 34,39 ****
--- 35,41 ----
       {metric_menu} &nbsp;&nbsp;
       {range_menu}&nbsp;&nbsp;
       {sort_menu}
+      {custom_time}
       </TD>
       <TD>
        <B>{alt_view}</B>
