Revision 804e829a
Added by Hamish Coleman over 17 years ago
- ID 804e829a283b38e749f2d39623b16b12df5a7fb1
| mrtg.cgi | ||
|---|---|---|
| 		if (!defined $fh) {
 | ||
| 			# FIXME globals
 | ||
| 			$warnings .= "Warning: Could not open $filename $!\n";
 | ||
| 			return;
 | ||
| 		}
 | ||
|  | ||
| 		#TODO - multi-line values
 | ||
| ... | ... | |
| 	#	defined($db->{target}->{$name}->{hosttype}) &&
 | ||
| 	#	defined($db->{hosttype}->{$hosttype})
 | ||
| 	my $hosttype = $db->{target}->{$name}->{_hosttype};
 | ||
| 	if (!defined($db->{hosttype}->{$hosttype})) {
 | ||
| 	if (defined($hosttype) && !defined($db->{hosttype}->{$hosttype})) {
 | ||
| 		$hosttype=undef;
 | ||
| 	}
 | ||
|  | ||
| ... | ... | |
| 	return 1;
 | ||
| }
 | ||
|  | ||
| sub emit_graph_period_chooser($$) {
 | ||
| 	my ($path,$this_graph_period) = @_;
 | ||
|  | ||
| 	my $selfurl = "?path=$path";
 | ||
| 	if (defined(param('debug'))) {
 | ||
| 		$selfurl .= '&debug=1';
 | ||
| 	}
 | ||
|  | ||
| 	if ($this_graph_period eq 'day') {
 | ||
| 		print 'Daily';
 | ||
| 	} else {
 | ||
| 		print a({-href=>$selfurl.'&graph=day',-target=>'_self'}, 'Daily');
 | ||
| 	}
 | ||
| 	print ' ';
 | ||
| 	if ($this_graph_period eq 'week') {
 | ||
| 		print 'Weekly';
 | ||
| 	} else {
 | ||
| 		print a({-href=>$selfurl.'&graph=week',-target=>'_self'}, 'Weekly')
 | ||
| 	}
 | ||
| 	print ' ';
 | ||
| 	if ($this_graph_period eq 'month') {
 | ||
| 		print 'Monthly';
 | ||
| 	} else {
 | ||
| 		print a({-href=>$selfurl.'&graph=month',-target=>'_self'}, 'Monthly')
 | ||
| 	}
 | ||
| 	print ' ';
 | ||
| 	if ($this_graph_period eq 'year') {
 | ||
| 		print 'Yearly';
 | ||
| 	} else {
 | ||
| 		print a({-href=>$selfurl.'&graph=year',-target=>'_self'}, 'Yearly')
 | ||
| 	}
 | ||
| 	print ' ';
 | ||
|  | ||
| 	print '(This List is ',$path,")\n";
 | ||
| }
 | ||
|  | ||
| sub print_graph_chooser($$$$) {
 | ||
| 	my ($this_graph,$list,$page,$changepage) = @_;
 | ||
| 	my ($this_graph_period,$list,$page,$changepage) = @_;
 | ||
|  | ||
| 	my $selfurl = "?page=$page&list=$list&";
 | ||
|  | ||
| 	if ($this_graph eq 'day') {
 | ||
| 	if ($this_graph_period eq 'day' ) {
 | ||
| 		print 'Daily';
 | ||
| 	} else {
 | ||
| 		print a({-href=>$selfurl.'graph=day',-target=>'_self'}, 'Daily');
 | ||
| 	}
 | ||
| 	print ' ';
 | ||
| 	if ($this_graph eq 'week') {
 | ||
| 	if ($this_graph_period eq 'week') {
 | ||
| 		print 'Weekly';
 | ||
| 	} else {
 | ||
| 		print a({-href=>$selfurl.'graph=week',-target=>'_self'}, 'Weekly')
 | ||
| 	}
 | ||
| 	print ' ';
 | ||
| 	if ($this_graph eq 'month') {
 | ||
| 	if ($this_graph_period eq 'month') {
 | ||
| 		print 'Monthly';
 | ||
| 	} else {
 | ||
| 		print a({-href=>$selfurl.'graph=month',-target=>'_self'}, 'Monthly')
 | ||
| 	}
 | ||
| 	print ' ';
 | ||
| 	if ($this_graph eq 'year') {
 | ||
| 	if ($this_graph_period eq 'year') {
 | ||
| 		print 'Yearly';
 | ||
| 	} else {
 | ||
| 		print a({-href=>$selfurl.'graph=year',-target=>'_self'}, 'Yearly')
 | ||
| ... | ... | |
| 	my $expires = gmtime (time + $interval * 2 + $guardband);
 | ||
|  | ||
| 	my $path = param('path');
 | ||
| 	my $graph = param('graph') || 'day';
 | ||
| 	my $graph_period = param('graph') || 'day';
 | ||
|  | ||
| 	print
 | ||
| 		"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
 | ||
| 		"<meta http-equiv=\"refresh\" content=$refresh>\n";
 | ||
| 	if ($path) {
 | ||
| 		print_graph_chooser($graph,'FIXME','FIXME','none');
 | ||
| 		emit_graph_period_chooser($path,$graph_period);
 | ||
| 		print "<br/>";
 | ||
| 		emit_path_contents($path,$graph);
 | ||
| 		emit_path_contents($path,$graph_period);
 | ||
| 	}
 | ||
|  | ||
| 	print <<EOF;
 | ||
Also available in: Unified diff
Add Day/Week/Month/Year selector. Clean up some small warnings