4 #set this for testing purposes only
5 #use CGI::Carp qw(fatalsToBrowser);
8 #some security-settings
9 $CGI::POST_MAX = 1024 * 100;
10 $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
12 #gather all mibs in smipath into @mibnames
13 my $smipath = "@smipath@";
14 my @smidirs = split(/:/,$smipath);
16 foreach my $dir (@smidirs) {
18 my @entries = grep !/^\.\.?\z/, readdir(MIBDIR);
20 @mibnames = (@mibnames, @entries);
28 my @mibs = param('mibs');
29 my $width = param('width');
30 my $height = param('height');
32 #parse options and add safe strings to the options-array
33 if (param('deprobs')) {
34 if (param('deprobs') eq "deprecated") {
35 @options = (@options, "--svg-show-deprecated");
36 } elsif (param('deprobs') eq "obsolete") {
37 @options = (@options, "--svg-show-depr-obsolete");
41 if (param('static')) {
42 @options = (@options, "--svg-static-output");
45 if ($width =~ /(\d+)/) {
46 if ($1 <= 2147483647) {
47 @options = (@options, "--svg-width=$1");
50 if ($height =~ /(\d+)/) {
51 if ($1 <= 2147483647) {
52 @options = (@options, "--svg-height=$1");
57 foreach my $mibname (@mibnames) {
58 foreach my $mib (@mibs) {
59 if ($mibname eq $mib) {
60 $mibname =~ /([\w\-]+)/;
61 @options = (@options, "$1");
67 if (param('uploadmib')) {
68 my $remotefh = upload('uploadmib');
70 = File::Temp->tempfile('tempMIBXXXX', DIR => '/tmp', UNLINK => 1)
71 or die "Error opening outfile\n";
77 @options = (@options, $localfn);
81 my $res = open (SMIDUMP, "-|");
82 die "Couldn't open pipe to subprocess" unless defined($res);
83 exec "@prefix@/bin/smidump",'-u','-f','svg',@options
84 or die "Couldn't exec smidump" if $res == 0;
90 if ($svglength eq 0) {
92 print start_html("MIB to SVG");
93 print h2("Sorry, smidump output contained no data.");
97 print header(-TYPE => "image/svg-xml");
105 print start_html("MIB to SVG");
106 print h2("Generate a SVG Diagram from MIB Modules");
107 print start_multipart_form();
109 print p("select one or more MIBs: ", scrolling_list(
111 -VALUES => [@mibnames],
116 print p("or upload a MIB: ", filefield(
120 print p("diagram width: ", textfield(
124 print p("diagram height: ", textfield(
131 -VALUES => [ qw(none deprecated obsolete) ],
134 none => "show only current objects",
135 deprecated => "show current and deprecated objects",
136 obsolete => "show all objects",
142 -LABEL => "generate a smaller, non-interactive SVG diagram",
145 print p(submit("generate SVG"), reset("reset form"));