commit b9a569f1c9c2d2be2a4112b9e1a704636728ded3
Author: Hamish Coleman <hamish@zot.org>
Date:   Fri Mar 21 15:08:19 2008 +1100

    Remove old, dead code

diff --git a/mrtg.cgi b/mrtg.cgi
index 8b13dd9..f90e273 100755
--- a/mrtg.cgi
+++ b/mrtg.cgi
@@ -65,7 +65,7 @@ sub config_save_val($$$$) {
 		return;
 	}
 
-	# Check for a name collision, and uniqueify
+	# Check for target name collision, and uniqueify
 	my $unique_target = $target;
 	my $unique_id = 1;
 	while (defined $db->{target}->{$unique_target}
@@ -420,297 +420,6 @@ sub emit_path_contents($$) {
 	}
 }
 
-sub init_tests(@) {
-	my (@config_files) = @_;
-
-	my $xsize_default = 500;
-	my $ysize_default = 135;
-
-	my $testmax=0;
-	my @list;
-	my %tests;
-
-	while(@config_files > 0){
-		my $cfg;
-
-		if (!open(In, $cfg = shift @config_files) ) {
-			$warnings .= "Warning: Could not open $cfg file\n";
-			next;
-		}
-
-		while(<In>){
-
-			#TODO - parse WorkDir: directives
-			#TODO - instantiate new tests from the "_" defaults
-
-			if ( $_ =~ /^([^#[][^[]+)\[(.*)\]:\s*(.+)$/ ) {
-				my $testnr;
-				my $var=lc $1;
-				my $testname=lc $2;
-				my $val=$3;
-
-				my $this_ysize;
-				my $this_xsize;
-				my $this_title;
-
-				if ( $var eq 'ysize' ) {
-					$this_ysize = $val +35;
-				} elsif ( $var eq 'xsize' ) {
-					$this_xsize = $val +100;
-				} elsif ( $var eq 'title' ) {
-					$this_title = $val;
-				}
-
-				# Skip any default initializers
-				if ($testname eq '_') {
-					# FIXME - quick-hack
-					if($this_xsize) {
-						$xsize_default = $this_xsize;
-					}
-					next;
-				}
-				if ($testname eq '^') {
-					next;
-				}
-
-				if (! exists $tests{$testname}) {
-					# initialize
-					$list[$testmax]->{xsize} = $xsize_default;
-					$list[$testmax]->{ysize} = $ysize_default;
-
-					$tests{$testname}=$testmax;
-					$list[$testmax]->{name} = $testname;
-					$testnr = $testmax;
-					# TODO - replace testmax with (scalar @list)
-					$testmax++;
-				} else {
-					$testnr=$tests{$testname};
-				}
-
-				$list[$testnr]->{ysize} = $this_ysize if $this_ysize;
-				$list[$testnr]->{xsize} = $this_xsize if $this_xsize;
-				$list[$testnr]->{title} = $this_title if $this_title;
-			}
-		}
-		close In;
-
-		config_load_file($cfg);
-	}
-
-	# check and update details for all known tests;
-	for my $i (@list) {
-		my $testname = $i->{name};
-		if (!exists($i->{title})) {
-			$i->{title}='UNTITLED';
-		}
-
-		# Default is GIF, unless a PNG file exists
-		$i->{imagetype} = 'gif';
-		if ( -e "$testname-day.png" ) {
-			$i->{imagetype} = "png";
-		}
-
-		# TODO - change the filename based on the displayed period
-		my $filename = $testname . "-day." . $i->{imagetype};
-		
-		my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
-			$atime,$mtime,$ctime,$blksize,$blocks)
-			= stat($filename);
-		if (!defined $mtime) {
-			# if we cannot stat the file, skip it
-			next;
-		}
-
-		$i->{mtime} = $mtime;
-
-		# find the newest file
-		if ($mtime > $gifdone) {
-			$gifdone = $mtime;
-		}
-	}
-
-	return @list;
-}
-
-sub init_lists(@) {
-	my (@tests) = @_;
-
-	my $l;
-
-	my %hostlist;
-	my %hosttypelist;
-	my %hosttypecount;
-
-	@{$l->{ALL}->{ALL}}=@tests;
-
-	for my $i (0..$#tests) {
-		my $testname = $tests[$i]->{name};
-
-		# Do not classify any test with no separators in it
-		if ($testname !~ /,/) {
-			push @{$l->{OTHER}->{OTHER}}, $tests[$i];
-			next;
-		}
-
-		my ($group,$host,$test) = split ',', $testname;
-
-		if (defined $group) {
-			push @{$l->{GROUP}->{$group}}, $tests[$i];
-		}
-		if (defined $host) {
-			push @{$l->{HOST}->{$host}}, $tests[$i];
-		}
-		if (defined $test) {
-			push @{$l->{TEST}->{$test}}, $tests[$i];
-		}
-
-		# TODO - this needs to have a better way...
-		# hosttype is the non digit hostname prefix - thus
-		# "proxy-1" and "proxy-2" would both end up in the
-		# "proxy-" hosttype
-		if ($host =~ m/^(.*[^0-9])(\d+)$/) {
-			my $hosttype = $1.'*';
-
-			# count each host only once
-			if (!defined $hostlist{$host}) {
-				$hostlist{$host}=1;
-				$hosttypecount{$hosttype}++;
-			}
-
-			push @{$hosttypelist{$hosttype}}, $tests[$i];
-		}
-	}
-
-	for my $i (keys %hosttypelist) {
-		if ($hosttypecount{$i} >1) {
-			push @{$l->{TYPE}->{$i}}, @{$hosttypelist{$i}};
-		}
-	}
-
-	maketree();
-	
-	return $l;
-}
-
-sub print_menu_table($$$$) {
-	my ($lists,$style,$target,$page) = @_;
-
-	print "\n<table border=2 cellpadding=2 cellspacing=0 style=\"margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse; font-size: 95%;\">\n";
-
-	if ($style eq 'wide') {
-		print "<tr>\n";
-
-		# print headings
-		for my $i (sort keys %{$lists}) {
-			print "<th>$i</th>\n";
-		}
-
-		print "</tr>";
-	}
-	
-	if ($style eq 'wide') {
-		print "<tr>\n";
-	}
-
-	# print contents
-	for my $i (sort keys %{$lists}) {
-		if ($style eq 'high') {
-			print "<tr><th>$i</tr>\n";
-			print "<tr>";
-		}
-		print " <td valign=top>\n";
-		for my $j (sort keys %{$lists->{$i}}) {
-			print "  ".a({-href=>"?page=$page&list=$i,$j",-target=>$target},"$j")."<br>\n";
-		}
-		print " </td>\n";
-
-		if ($style eq 'high') {
-			print "</tr>\n";
-		}
-	}
-
-	if ($style eq 'wide') {
-		print "</tr>";
-	}
-
-	print "</table>\n";
-}
-
-sub print_treemenu($$) {
-	my ($style,$lists) = @_;
-
-	my $page = 'list';
-	my $target = 'R';
-
-	if ($style ne 'frame') {
-		print "USEFRAMES = 0\n";
-		print "PRESERVESTATE =1\n";
-		# USEICONS = 0
-		# WRAPTEXT = 1
-		$page=$style;	
-		$target='S';
-	}
-	print "USETEXTLINKS = 1\n";
-	print "STARTALLOPEN = 0\n";
-	print "HIGHLIGHT = 1\n";
-	print "ICONPATH = ''\n";
-
-	print 'foldersTree = gFld("<i>MRTG Tree</i>", "javascript:undefined")',"\n";
-	print 'foldersTree.treeID = "Frameless"',"\n";
-	
-	# print contents
-	for my $i (sort keys %{$lists}) {
-
-		print "m$i = insFld(foldersTree, gFld(\"$i\", \"javascript:undefined\"))\n";
-
-		for my $j (sort keys %{$lists->{$i}}) {
-			print "insDoc(m$i, gLnk(\"$target\", \"$j\", \"?page=$page&list=$i,$j\"))\n";
-		}
-	}
-
-	emit_tree_one('foldersTree','',$db->{tree});
-	
-}
-
-sub print_list($$$$) {
-	my ($lists,$graph,$list,$target) = @_;
-
-	if (!defined $list) {
-		return undef;
-	}
-	if (!defined $lists) {
-		return undef;
-	}
-	
-	my @wantlist = split /,/,$list;
-
-	my @list = @{$lists->{$wantlist[0]}->{$wantlist[1]}};
-
-	for my $router_num (0..$#list){
-		my $router = $list[$router_num];
-
-		# FIXME - what if mtime is undef?
-		my $time = localtime $router->{mtime}; # $st_mtime saved in above loop
-		($time) = $time =~ /(\d+:\d+:\d+)/; # Just the time
-
-		print "$time <b>$router->{title}</b><br/>";
-
-		my ($ysize, $xsize);
-		$ysize = $router->{ysize};
-		$xsize = $router->{xsize};
-
-		print a({-href=>$router->{name}.".html",-target=>$target},
-			img{
-				-src=>$router->{name}."-$graph.".$router->{imagetype},
-				-height=>"$ysize",
-				-width=>"$xsize"
-			}
-		);
-		print br,br,"\n";
-	}
-	return 1;
-}
-
 sub emit_graph_period_chooser($$) {
 	my ($path,$this_graph_period) = @_;
 
@@ -747,52 +456,6 @@ sub emit_graph_period_chooser($$) {
 	print '(This List is ',$path,")\n";
 }
 
-sub print_graph_chooser($$$$) {
-	my ($this_graph_period,$list,$page,$changepage) = @_;
-
-	my $selfurl = "?page=$page&list=$list&";
-
-	if ($this_graph_period eq 'day' ) {
-		print 'Daily';
-	} else {
-		print a({-href=>$selfurl.'graph=day',-target=>'_self'}, 'Daily');
-	}
-	print '&nbsp;';
-	if ($this_graph_period eq 'week') {
-		print 'Weekly';
-	} else {
-		print a({-href=>$selfurl.'graph=week',-target=>'_self'}, 'Weekly')
-	}
-	print '&nbsp;';
-	if ($this_graph_period eq 'month') {
-		print 'Monthly';
-	} else {
-		print a({-href=>$selfurl.'graph=month',-target=>'_self'}, 'Monthly')
-	}
-	print '&nbsp;';
-	if ($this_graph_period eq 'year') {
-		print 'Yearly';
-	} else {
-		print a({-href=>$selfurl.'graph=year',-target=>'_self'}, 'Yearly')
-	}
-	print '&nbsp;';
-
-	print '&nbsp;';
-	if (defined $changepage) {
-		print a({-href=>"?page=$changepage"}, 'Change List'), '&nbsp;';
-	}
-	print '(This List is ',param('list'),")\n";
-}
-
-sub print_menutypelist() {
-	print a({-href=>"?page=none",-target=>"_top"}, "Menu Across");
-	print br;
-	print a({-href=>"?page=noframe",-target=>"_top"}, "Menu Down");
-	print br;
-	print a({-href=>"?page=treenf",-target=>"_top"}, "Tree (NF)");
-	print br;
-	print a({-href=>"?page=treeview",-target=>"_top"}, "Tree (Frames)");
-}
 
 my $this_host = hostname;
 if(!defined param('page')) {
@@ -903,261 +566,8 @@ EOF
 EOF
 
 	print end_html;
-} else {
-
-my $page = param('page') || 'treenf';
-my @tests;
-my $lists;
-
-if($page eq 'treeview') {
-	print "Content-type: text/html\n\n";
-	print "<html><head><title>$this_host MRTG Index (V$VERSION)</title></head>\n";
-	print "<script>\n";
-	print "function op() { }\n";
-	print "</script>\n";
-	print '<frameset cols="200,*">'; # FIXME onresize if navigator.family==nn4
-	print '<frame src="?page=treemenu" name=treeframe>';
-	print '<frame src="javascript:parent.op()" name=basefrm>';
-	print "</frameset>\n";
-	print "</html>\n";
-
-} elsif($page eq 'list') {
-	print header,
-		start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
-		"\n";
-
-	@tests = init_tests(@config_files);
-	$lists = init_lists(@tests);
-
-	# Time the next update to occur a little while after the next interval completes
-	my $interval = 300; # 5 min update interval
-	my $guardband = 15; # updates occur this many seconds after predicted gif completion
-	my $refresh = $interval + $guardband + $gifdone - time; # predict how long until next update
-	$refresh = $interval if $refresh <= $guardband;
-	my $expires = gmtime (time + $interval * 2 + $guardband);
-
-	my $list = param('list');
-	my $graph = param('graph') || 'day';
-
-	print
-		"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
-		"<meta http-equiv=\"refresh\" content=$refresh>\n";
-	if ($list) {
-		print_graph_chooser($graph,$list,$page,'none');
-		print "<br/>";
-		print_list($lists,$graph,$list,'basefrm');
-	}
-	print end_html;
-} elsif($page eq 'treemenu') {
-	print header,
-		start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
-		"\n";
-
-	@tests = init_tests(@config_files);
-	$lists = init_lists(@tests);
-
-	print <<EOF;
-  <STYLE>
-    BODY {
-      background-color: white;}
-    TD {
-      font-size: 10pt; 
-      font-family: verdana,helvetica; 
-      text-decoration: none;
-      white-space:nowrap;}
-    A {
-      text-decoration: none;
-      color: black;}
-    .specialClass {
-      font-family:garamond; 
-      font-size:12pt;
-      color:green;
-      font-weight:bold;
-      text-decoration:underline}
-  </STYLE>
-EOF
-	print '<script src="ua.js"></script>';
-	print '<script src="ftiens4.js"></script>';
-	print '<script>';
-	print_treemenu('frame',$lists);
-	print '</script>';
-	print '<DIV style="position:absolute; top:0; left:0;"><TABLE border=0><TR><TD><FONT size=-2><A style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank>Javascript Tree Menu</A></FONT></TD></TR></TABLE></DIV>';
-	print '<script>initializeDocument()</script>';
-	print '<NOSCRIPT>A tree for site navigation will open here if you enable JavaScript in your browser.</NOSCRIPT>';
-	print hr;
-	print_menutypelist();
-
-	print end_html;
-} elsif($page eq 'treenf') {
-	print header,
-		start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)",
-			-bgcolor=>"white",
-			-leftmargin=>"0", -topmargin=>"0",
-			-marginheight=>"0", -marginwidth=>"0",
-			-onResize=>"if (navigator.family == 'nn4') window.location.reload()" ),
-		"\n";
-
-	@tests = init_tests(@config_files);
-	$lists = init_lists(@tests);
-
-	print <<EOF;
-  <STYLE>
-   /*                                                          */
-   /* Styles for the tree.                                     */
-   /*                                                          */
-   SPAN.TreeviewSpanArea A {
-     font-size: 10pt; 
-     font-family: verdana,helvetica; 
-     text-decoration: none;
-     color: black;}
-   SPAN.TreeviewSpanArea A:hover {
-     color: '#820082';}
-
-   /*                                                          */
-   /* Styles for the remainder of the document.                */
-   /*                                                          */
-   BODY {
-     background-color: white;}
-   TD {
-     font-size: 10pt; 
-     font-family: verdana,helvetica;}
-  </STYLE>
-EOF
-	print '<script src="ua.js"></script>';
-	print '<script src="ftiens4.js"></script>';
-	print '<script>';
-	print_treemenu('treenf',$lists);
-	print '</script>';
-	print <<EOF;
- <TABLE cellpadding="0" cellspacing="0" border="0" width="772">
-  <TR>
-   <TD width="178" valign="top">
-
-    <TABLE cellpadding="4" cellspacing="0" border="0" width="100%">
-     <TR>
-      <TD bgcolor="#ECECD9">
-
-        <TABLE cellspacing="0" cellpadding="2" border="0" width="100%">
-         <TR>
-	  <td width="200" valign="top" bgcolor="#efefef" style="border-right: 1px solid rgb(170, 170, 170); padding: 5px;">
-
- <TABLE border=0><TR><TD><FONT size=-2><A style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank /></FONT></TD></TR></TABLE>
-
- <SPAN class=TreeviewSpanArea>
-  <SCRIPT>initializeDocument()</SCRIPT>
-  <NOSCRIPT>
-   A tree for site navigation will open here if you enable JavaScript in your browser.
-  </NOSCRIPT>
- </SPAN>
-EOF
-
-	print hr;
-	print_menutypelist();
-	print <<EOF;
-          </TD>
-         </TR>
-        </TABLE>
-
-       </TD>
-      </TR>
-     </TABLE>
-
-    </TD>
-    <TD bgcolor="white" valign="top">
-
-     <TABLE cellpadding="10" cellspacing="0" border="0" width="100%">
-      <TR>
-       <TD>
-EOF
-
-	# Time the next update to occur a little while after the next interval completes
-	my $interval = 300; # 5 min update interval
-	my $guardband = 15; # updates occur this many seconds after predicted gif completion
-	my $refresh = $interval + $guardband + $gifdone - time; # predict how long until next update
-	$refresh = $interval if $refresh <= $guardband;
-	my $expires = gmtime (time + $interval * 2 + $guardband);
-
-	my $list = param('list');
-	my $graph = param('graph') || 'day';
-
-	print
-		"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
-		"<meta http-equiv=\"refresh\" content=$refresh>\n";
-	if ($list) {
-		print_graph_chooser($graph,$list,$page,'none');
-		print "<br/>";
-		print_list($lists,$graph,$list,'_self');
-	}
-
-	print <<EOF;
-       </TD>
-      </TR>
-     </TABLE>
-
-    </TD>
-   </TR>
-  </TABLE>
-EOF
-
-	print end_html;
-} elsif($page eq 'noframe') {
-	print header,
-		start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
-		"\n";
-
-	@tests = init_tests(@config_files);
-	$lists = init_lists(@tests);
-
-	# FIXME - duplicated time calculations from above
-	# Time the next update to occur a little while after the next interval completes
-	my $interval = 300; # 5 min update interval
-	my $guardband = 15; # updates occur this many seconds after predicted gif completion
-	my $refresh = $interval + $guardband + $gifdone - time; # predict how long until next update
-	$refresh = $interval if $refresh <= $guardband;
-	my $expires = gmtime (time + $interval * 2 + $guardband);
-
-	my $list = param('list');
-	my $graph = param('graph') || 'day';
-
-	print
-		"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
-		"<meta http-equiv=\"refresh\" content=$refresh>\n";
-
-	print "<table cellpadding=2 cellspacing=0>\n";
-
-	print "<tr><td valign=top>";
-	print_menu_table($lists,'high','_self','noframe');
-
-	print "<td valign=top>\n";
-	if ($list) {
-		print_graph_chooser($graph,$list,$page,'noframe');
-		print "<br/>";
-		print_list($lists,$graph,param('list'),'_self');
-	}
-
-	print "</table>\n";
-	print end_html;
-	
-} elsif($page eq 'none') {
-	print header,
-		start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
-		"\n";
-
-	@tests = init_tests(@config_files);
-	$lists = init_lists(@tests);
-	print table(
-		{-width=>"100\%"},
-		TR(td("Select which list to show"))
-	);
-	print_menu_table($lists,'wide','_self','list');
-	print "\n","Direct questions and feedback to ",
-		a({-href=>"mailto:hamish\@zot.org"}, "Hamish"),
-		" (Version $VERSION)",
-		end_html;
-
 }
 
-}
 
 if (param('debug')) {
 	#print "<pre>\n", "$warnings", "</pre>\n";
