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