1 | <?php |
---|
2 | # Check if this context is private. |
---|
3 | include_once "$GANGLIA_PATH/auth.php"; |
---|
4 | checkcontrol(); |
---|
5 | checkprivate(); |
---|
6 | |
---|
7 | if ( $context == "control" && $controlroom < 0 ) |
---|
8 | $header = "header-nobanner"; |
---|
9 | else |
---|
10 | $header = "header"; |
---|
11 | |
---|
12 | $tpl = new TemplatePower( "templates/header.tpl" ); |
---|
13 | $tpl->prepare(); |
---|
14 | |
---|
15 | # Maintain our path through the grid tree. |
---|
16 | $me = $self . "@" . $grid[$self][AUTHORITY]; |
---|
17 | if ($initgrid) |
---|
18 | { |
---|
19 | $gridstack = array(); |
---|
20 | $gridstack[] = $me; |
---|
21 | } |
---|
22 | else if ($gridwalk=="fwd") |
---|
23 | { |
---|
24 | # push our info on gridstack, format is "name@url>name2@url". |
---|
25 | if (end($gridstack) != $me) |
---|
26 | { |
---|
27 | $gridstack[] = $me; |
---|
28 | } |
---|
29 | } |
---|
30 | else if ($gridwalk=="back") |
---|
31 | { |
---|
32 | # pop a single grid off stack. |
---|
33 | if (end($gridstack) != $me) |
---|
34 | { |
---|
35 | array_pop($gridstack); |
---|
36 | } |
---|
37 | } |
---|
38 | $gridstack_str = join(">", $gridstack); |
---|
39 | $gridstack_url = rawurlencode($gridstack_str); |
---|
40 | |
---|
41 | if ($initgrid or $gridwalk) |
---|
42 | { |
---|
43 | # Use cookie so we dont have to pass gridstack around within this site. |
---|
44 | # Cookie values are automatically urlencoded. Expires in a day. |
---|
45 | setcookie("gs", $gridstack_str, time() + 86400); |
---|
46 | } |
---|
47 | |
---|
48 | # Invariant: back pointer is second-to-last element of gridstack. Grid stack never |
---|
49 | # has duplicate entries. |
---|
50 | list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack)-2]); |
---|
51 | |
---|
52 | # Setup a redirect to a remote server if you choose a grid from pulldown menu. Tell |
---|
53 | # destination server that we're walking foward in the grid tree. |
---|
54 | if (strstr($clustername, "http://")) |
---|
55 | { |
---|
56 | $tpl->assign("refresh", "0"); |
---|
57 | $tpl->assign("redirect", ";URL=$clustername?gw=fwd&gs=$gridstack_url"); |
---|
58 | echo "<h2>Redirecting, please wait...</h2>"; |
---|
59 | $tpl->printToScreen(); |
---|
60 | exit; |
---|
61 | } |
---|
62 | $tpl->assign("refresh", $default_refresh); |
---|
63 | |
---|
64 | $tpl->assign( "date", date("r")); |
---|
65 | $tpl->assign( "page_title", $title ); |
---|
66 | |
---|
67 | # The page to go to when "Get Fresh Data" is pressed. |
---|
68 | if (isset($page)) |
---|
69 | $tpl->assign("page",$page); |
---|
70 | else |
---|
71 | $tpl->assign("page","./"); |
---|
72 | |
---|
73 | # Templated Logo image |
---|
74 | $tpl->assign("images","./templates/$template_name/images"); |
---|
75 | |
---|
76 | # |
---|
77 | # Used when making graphs via graph.php. Included in most URLs |
---|
78 | # |
---|
79 | $sort_url=rawurlencode($sort); |
---|
80 | $get_metric_string = "m=$metric&r=$range&s=$sort_url&hc=$hostcols"; |
---|
81 | if ($jobrange and $jobstart) |
---|
82 | $get_metric_string .= "&jr=$jobrange&js=$jobstart"; |
---|
83 | |
---|
84 | # Set the Alternate view link. |
---|
85 | $cluster_url=rawurlencode($clustername); |
---|
86 | $node_url=rawurlencode($hostname); |
---|
87 | |
---|
88 | # Make some information available to templates. |
---|
89 | $tpl->assign("cluster_url", $cluster_url); |
---|
90 | |
---|
91 | # Build the node_menu |
---|
92 | $node_menu = ""; |
---|
93 | |
---|
94 | if ($parentgrid) |
---|
95 | { |
---|
96 | $node_menu .= "<B><A HREF=\"$parentlink?gw=back&gs=$gridstack_url\">". |
---|
97 | "$parentgrid $meta_designator</A></B> "; |
---|
98 | $node_menu .= "<B>></B>\n"; |
---|
99 | } |
---|
100 | |
---|
101 | # Show grid. |
---|
102 | $mygrid = ($self == "unspecified") ? "" : $self; |
---|
103 | $node_menu .= "<B><A HREF=\"./?$get_metric_string\">$mygrid $meta_designator</A> "; |
---|
104 | $node_menu .= "<B>></B>\n"; |
---|
105 | |
---|
106 | if ($physical) |
---|
107 | $node_menu .= hiddenvar("p", $physical); |
---|
108 | |
---|
109 | if ( $clustername ) |
---|
110 | { |
---|
111 | $url = rawurlencode($clustername); |
---|
112 | $node_menu .= "<B><A HREF=\"./?c=$url&$get_metric_string\">$clustername</A></B> "; |
---|
113 | //$node_menu .= "<B>></B>\n"; |
---|
114 | $node_menu .= hiddenvar("c", $clustername); |
---|
115 | } |
---|
116 | else |
---|
117 | { |
---|
118 | # No cluster has been specified, so drop in a list |
---|
119 | $node_menu .= "<SELECT NAME=\"c\" OnChange=\"ganglia_form.submit();\">\n"; |
---|
120 | $node_menu .= "<OPTION VALUE=\"\">--Choose a Source\n"; |
---|
121 | ksort($grid); |
---|
122 | foreach( $grid as $k => $v ) |
---|
123 | { |
---|
124 | if ($k==$self) continue; |
---|
125 | if ($v[GRID]) |
---|
126 | { |
---|
127 | $url = $v[AUTHORITY]; |
---|
128 | $node_menu .="<OPTION VALUE=\"$url\">$k $meta_designator\n"; |
---|
129 | } |
---|
130 | else |
---|
131 | { |
---|
132 | $url = rawurlencode($k); |
---|
133 | $node_menu .="<OPTION VALUE=\"$url\">$k\n"; |
---|
134 | } |
---|
135 | } |
---|
136 | $node_menu .= "</SELECT>\n"; |
---|
137 | } |
---|
138 | |
---|
139 | $tpl->assign("node_menu", $node_menu); |
---|
140 | |
---|
141 | # Make sure that no data is cached.. |
---|
142 | header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Date in the past |
---|
143 | header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); # always modified |
---|
144 | header ("Cache-Control: no-cache, must-revalidate"); # HTTP/1.1 |
---|
145 | header ("Pragma: no-cache"); # HTTP/1.0 |
---|
146 | |
---|
147 | $tpl->printToScreen(); |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | ?> |
---|