| 
									
										
										
										
											2010-07-25 14:21:05 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-17 19:14:44 +00:00
										 |  |  | unset($vars['page']); | 
					
						
							| 
									
										
										
										
											2010-07-25 14:21:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-25 12:24:34 +00:00
										 |  |  | // Setup here
 | 
					
						
							| 
									
										
										
										
											2011-09-17 19:14:44 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | if($_SESSION['widescreen']) { | 
					
						
							|  |  |  |     $graph_width=1700; | 
					
						
							|  |  |  |     $thumb_width=180; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | else { | 
					
						
							|  |  |  |     $graph_width=1075; | 
					
						
							|  |  |  |     $thumb_width=113; | 
					
						
							| 
									
										
										
										
											2011-09-17 19:14:44 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | if (!is_numeric($vars['from'])) { | 
					
						
							|  |  |  |     $vars['from'] = $config['time']['day']; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | if (!is_numeric($vars['to'])) { | 
					
						
							|  |  |  |     $vars['to']   = $config['time']['now']; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-09-17 19:14:44 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-10 17:36:28 +00:00
										 |  |  | preg_match('/^(?P<type>[A-Za-z0-9]+)_(?P<subtype>.+)/', $vars['type'], $graphtype); | 
					
						
							| 
									
										
										
										
											2010-07-25 14:21:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | $type = $graphtype['type']; | 
					
						
							|  |  |  | $subtype = $graphtype['subtype']; | 
					
						
							| 
									
										
										
										
											2011-09-17 19:14:44 +00:00
										 |  |  | $id = $vars['id']; | 
					
						
							| 
									
										
										
										
											2010-07-25 14:21:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | if(is_numeric($vars['device'])) { | 
					
						
							|  |  |  |     $device = device_by_id_cache($vars['device']); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | elseif(!empty($vars['device'])) { | 
					
						
							|  |  |  |     $device = device_by_name($vars['device']); | 
					
						
							| 
									
										
										
										
											2012-05-11 13:26:14 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | if (is_file("includes/graphs/".$type."/auth.inc.php")) { | 
					
						
							|  |  |  |     require "includes/graphs/".$type."/auth.inc.php"; | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-08-01 14:17:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | if (!$auth) { | 
					
						
							|  |  |  |     require 'includes/error-no-perm.inc.php'; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | else { | 
					
						
							|  |  |  |     if (isset($config['graph_types'][$type][$subtype]['descr'])) { | 
					
						
							|  |  |  |         $title .= " :: ".$config['graph_types'][$type][$subtype]['descr']; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         $title .= " :: ".ucfirst($subtype); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $graph_array = $vars; | 
					
						
							|  |  |  |     $graph_array['height'] = "60"; | 
					
						
							|  |  |  |     $graph_array['width']  = $thumb_width; | 
					
						
							|  |  |  |     $graph_array['legend'] = "no"; | 
					
						
							|  |  |  |     $graph_array['to']     = $config['time']['now']; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     print_optionbar_start(); | 
					
						
							|  |  |  |     echo($title); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     echo('<div style="float: right;">'); | 
					
						
							|  |  |  | ?>
 | 
					
						
							| 
									
										
										
										
											2012-04-17 14:02:51 +00:00
										 |  |  |   <form action=""> | 
					
						
							|  |  |  |   <select name='type' id='type' | 
					
						
							|  |  |  |     onchange="window.open(this.options[this.selectedIndex].value,'_top')" > | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2012-04-17 14:02:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     foreach (get_graph_subtypes($type) as $avail_type) { | 
					
						
							|  |  |  |         echo("<option value='".generate_url($vars, array('type' => $type."_".$avail_type, 'page' => "graphs"))."'"); | 
					
						
							|  |  |  |         if ($avail_type == $subtype) { | 
					
						
							|  |  |  |             echo(" selected"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         $display_type = is_mib_graph($type, $avail_type) ? $avail_type : nicecase($avail_type); | 
					
						
							|  |  |  |         echo(">$display_type</option>"); | 
					
						
							| 
									
										
										
										
											2015-06-13 22:55:18 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | ?>
 | 
					
						
							| 
									
										
										
										
											2012-04-24 18:19:07 +00:00
										 |  |  |     </select> | 
					
						
							|  |  |  |   </form> | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  |     echo('</div>'); | 
					
						
							| 
									
										
										
										
											2012-04-17 14:02:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     print_optionbar_end(); | 
					
						
							| 
									
										
										
										
											2010-07-25 14:21:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     print_optionbar_start(); | 
					
						
							| 
									
										
										
										
											2010-07-25 14:21:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     $thumb_array = array('sixhour' => '6 Hours', 'day' => '24 Hours', 'twoday' => '48 Hours', 'week' => 'One Week', 'twoweek' => 'Two Weeks', | 
					
						
							|  |  |  |         'month' => 'One Month', 'twomonth' => 'Two Months','year' => 'One Year', 'twoyear' => 'Two Years'); | 
					
						
							| 
									
										
										
										
											2010-07-25 14:21:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-23 11:23:04 +00:00
										 |  |  |      echo('<table width=100% class="thumbnail_graph_table"><tr>'); | 
					
						
							| 
									
										
										
										
											2011-09-25 22:37:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     foreach ($thumb_array as $period => $text) { | 
					
						
							|  |  |  |         $graph_array['from']   = $config['time'][$period]; | 
					
						
							| 
									
										
										
										
											2010-07-25 14:21:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |         $link_array = $vars; | 
					
						
							|  |  |  |         $link_array['from'] = $graph_array['from']; | 
					
						
							|  |  |  |         $link_array['to'] = $graph_array['to']; | 
					
						
							|  |  |  |         $link_array['page'] = "graphs"; | 
					
						
							|  |  |  |         $link = generate_url($link_array); | 
					
						
							| 
									
										
										
										
											2010-07-25 14:21:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |         echo('<td align=center>'); | 
					
						
							| 
									
										
										
										
											2015-10-01 17:01:33 +05:30
										 |  |  |         echo('<b>'.$text.'</b><br>'); | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |         echo('<a href="'.$link.'">'); | 
					
						
							| 
									
										
										
										
											2015-07-16 12:42:58 -04:00
										 |  |  |         echo generate_lazy_graph_tag($graph_array); | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |         echo('</a>'); | 
					
						
							|  |  |  |         echo('</td>'); | 
					
						
							| 
									
										
										
										
											2011-09-25 22:37:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-07-25 14:21:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     echo('</tr></table>'); | 
					
						
							| 
									
										
										
										
											2011-09-17 19:14:44 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     $graph_array = $vars; | 
					
						
							|  |  |  |     $graph_array['height'] = "300"; | 
					
						
							|  |  |  |     $graph_array['width']  = $graph_width; | 
					
						
							| 
									
										
										
										
											2011-09-20 09:55:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-20 14:39:19 +00:00
										 |  |  |     if($_SESSION['screen_width']) { | 
					
						
							| 
									
										
										
										
											2015-11-23 11:23:04 +00:00
										 |  |  |         if($_SESSION['screen_width'] > 800) { | 
					
						
							|  |  |  |             $graph_array['width'] = ($_SESSION['screen_width'] - ($_SESSION['screen_width']/10)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             $graph_array['width'] = ($_SESSION['screen_width'] - ($_SESSION['screen_width']/4)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-11-20 14:39:19 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if($_SESSION['screen_height']) { | 
					
						
							| 
									
										
										
										
											2015-11-23 11:23:04 +00:00
										 |  |  |         if($_SESSION['screen_height'] > 960 ) {  | 
					
						
							|  |  |  |             $graph_array['height'] = ($_SESSION['screen_height'] - ($_SESSION['screen_height']/2)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             $graph_array['height'] = ($_SESSION['screen_height'] - ($_SESSION['screen_height']/1.5)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-11-20 14:39:19 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     echo("<hr />"); | 
					
						
							| 
									
										
										
										
											2011-09-25 22:37:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-20 21:35:08 +00:00
										 |  |  |     include_once 'includes/print-date-selector.inc.php'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-23 16:37:21 +05:30
										 |  |  |     echo ('<div style="padding-top: 5px";></div>'); | 
					
						
							|  |  |  |     echo('<center>'); | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     if ($vars['legend'] == "no") { | 
					
						
							|  |  |  |         echo(generate_link("Show Legend",$vars, array('page' => "graphs", 'legend' => NULL))); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         echo(generate_link("Hide Legend",$vars, array('page' => "graphs", 'legend' => "no"))); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-09-25 22:37:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     // FIXME : do this properly
 | 
					
						
							|  |  |  |     #  if ($type == "port" && $subtype == "bits")
 | 
					
						
							|  |  |  |     #  {
 | 
					
						
							| 
									
										
										
										
											2012-04-18 10:51:18 +00:00
										 |  |  |     echo(' | '); | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     if ($vars['previous'] == "yes") { | 
					
						
							|  |  |  |         echo(generate_link("Hide Previous",$vars, array('page' => "graphs", 'previous' => NULL))); | 
					
						
							| 
									
										
										
										
											2012-04-18 10:51:18 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     else { | 
					
						
							|  |  |  |         echo(generate_link("Show Previous",$vars, array('page' => "graphs", 'previous' => "yes"))); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     #  }
 | 
					
						
							| 
									
										
										
										
											2012-04-18 10:51:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-23 16:37:21 +05:30
										 |  |  |     echo(' | '); | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     if ($vars['showcommand'] == "yes") { | 
					
						
							|  |  |  |         echo(generate_link("Hide RRD Command",$vars, array('page' => "graphs", 'showcommand' => NULL))); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         echo(generate_link("Show RRD Command",$vars, array('page' => "graphs", 'showcommand' => "yes"))); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-08-23 16:37:21 +05:30
										 |  |  |     echo('</center>'); | 
					
						
							| 
									
										
										
										
											2012-01-12 12:51:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     print_optionbar_end(); | 
					
						
							| 
									
										
										
										
											2011-09-25 22:37:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     echo generate_graph_js_state($graph_array); | 
					
						
							| 
									
										
										
										
											2011-06-14 14:04:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-22 17:58:10 +05:30
										 |  |  |     echo('<div style="width: '.$graph_array['width'].'; margin: auto;"><center>'); | 
					
						
							| 
									
										
										
										
											2015-07-16 12:42:58 -04:00
										 |  |  |     echo generate_lazy_graph_tag($graph_array); | 
					
						
							| 
									
										
										
										
											2015-08-22 17:58:10 +05:30
										 |  |  |     echo("</center></div>"); | 
					
						
							| 
									
										
										
										
											2012-01-12 12:51:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     if (isset($config['graph_descr'][$vars['type']])) { | 
					
						
							| 
									
										
										
										
											2012-03-27 16:53:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |         print_optionbar_start(); | 
					
						
							|  |  |  |         echo('<div style="float: left; width: 30px;"> | 
					
						
							|  |  |  |             <div style="margin: auto auto;"> | 
					
						
							| 
									
										
										
										
											2012-04-05 13:11:48 +00:00
										 |  |  |             <img valign=absmiddle src="images/16/information.png" /> | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |             </div> | 
					
						
							|  |  |  |             </div>'); | 
					
						
							|  |  |  |         echo($config['graph_descr'][$vars['type']]); | 
					
						
							|  |  |  |         print_optionbar_end(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-03-27 16:53:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     if ($vars['showcommand']) { | 
					
						
							|  |  |  |         $_GET = $graph_array; | 
					
						
							|  |  |  |         $command_only = 1; | 
					
						
							| 
									
										
										
										
											2012-04-06 13:56:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |         require 'includes/graphs/graph.inc.php'; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-08-01 14:17:06 +00:00
										 |  |  | } |