| 1 |
#!/usr/bin/perl -w |
| 2 |
# |
| 3 |
# This file is used to redirect bweb to the exact file of the documentation |
| 4 |
# |
| 5 |
use strict; |
| 6 |
use Data::Dumper; |
| 7 |
use CGI; |
| 8 |
|
| 9 |
# Creation mode, put the directory to scan in argument |
| 10 |
if (scalar(@ARGV) > 0) { |
| 11 |
my %index; |
| 12 |
my $dir = $ARGV[0]; |
| 13 |
# Index this directory |
| 14 |
open(FP, ">.idx") or die "ERROR: unable to open index file"; |
| 15 |
|
| 16 |
chdir($dir) or die "ERROR: Unable to chdir to $dir"; |
| 17 |
|
| 18 |
foreach my $l (`grep '<A NAME="' *.html`) { |
| 19 |
|
| 20 |
# Monitor_Configuration.html:<A NAME="MonitorResource"></A> |
| 21 |
if ($l =~ m/^([^:]+):<A NAME="(.+?)">/) { |
| 22 |
my ($key, $file) = ($2, $1); |
| 23 |
if ($key !~ /^(tex2html|\d)/) { |
| 24 |
$index{$key} = $file; |
| 25 |
} |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
print FP Data::Dumper::Dumper(\%index); |
| 30 |
close(FP); |
| 31 |
exit; |
| 32 |
} |
| 33 |
|
| 34 |
################################################################ |
| 35 |
|
| 36 |
my $base = "http://www.baculasystems.com/docs"; |
| 37 |
if (!CGI::param()) { |
| 38 |
print CGI::redirect($base); |
| 39 |
exit 0; |
| 40 |
} |
| 41 |
|
| 42 |
my $version = CGI:param('version') || '6.0'; |
| 43 |
if ($version !~ /^(\d+\.\d+)$/) { |
| 44 |
print CGI::redirect($base); |
| 45 |
exit 0; |
| 46 |
} |
| 47 |
|
| 48 |
$base = "$base/docs/${version}.x-manuals/en/"; |
| 49 |
|
| 50 |
# Key arg is mandatory |
| 51 |
my $key = CGI::param('key'); |
| 52 |
if ($key !~ /^([\w\d:\.\-]{1,127})$/) { |
| 53 |
print CGI::redirect($base); |
| 54 |
} |
| 55 |
$key = $1; |
| 56 |
|
| 57 |
my $manual = CGI::param('manual') || "main"; |
| 58 |
if ($manual !~ /^(main|console|operator)$/) { |
| 59 |
print CGI::redirect("$base/main/main"); |
| 60 |
} |
| 61 |
$manual = $1; |
| 62 |
|
| 63 |
if (!open(FP, ".idx")) { |
| 64 |
print CGI::redirect($base); |
| 65 |
exit 0; |
| 66 |
} |
| 67 |
|
| 68 |
my $f=''; my $tmpbuffer; |
| 69 |
while(read FP,$tmpbuffer,4096) |
| 70 |
{ |
| 71 |
$f .= $tmpbuffer; |
| 72 |
} |
| 73 |
close(FP); |
| 74 |
|
| 75 |
our $VAR1; |
| 76 |
|
| 77 |
no strict; # I have no idea of the contents of the file |
| 78 |
eval "$f" ; |
| 79 |
use strict; |
| 80 |
|
| 81 |
if (exists $VAR1->{$key}) { |
| 82 |
print CGI::redirect("$base/$manual/$manual" . $VAR1->{$key} . '#' . $key); |
| 83 |
exit 0; |
| 84 |
} |
| 85 |
|
| 86 |
print CGI::redirect($base); |