3 # Displays help HTML for some module, with substitutions
5 BEGIN { push(@INC, ".."); };
8 $trust_unknown_referers = 1;
10 &error_setup($text{'help_err'});
11 $ENV{'PATH_INFO'} !~ /[\\\&\;\`\'\"\|\*\?\~\<\>\^\(\)\[\]\{\}\$\n\r]/ ||
12 &error($text{'help_epath'});
13 $ENV{'PATH_INFO'} =~ /^\/(\S+)\/(\S+)$/ || &error($text{'help_epath'});
14 $module = $1; $file = $2;
16 # if it ends with .gif assume it is a direct URL
17 if ($file =~ /\.(gif|jpg|jpeg|png)$/i) {
18 &redirect("$module/$file");
23 $path = &help_file($module, $file);
25 open(HELP, $path) || &helperror(&text('help_efile', $path));
26 read(HELP, $help, $st[7]);
29 # find and replace the <header> section
30 if ($help =~ s/<header>([^<]+)<\/header>//i) {
32 print &ui_subheading($1);
35 &helperror($text{'help_eheader'});
38 # replace any explicit use of <hr> with the ui-lib function
40 $help =~ s/<hr>/$uihr/ig;
42 # find and replace the <footer> section
43 $help =~ s/<footer>/<p>/i;
45 # find and replace <include> directives
46 $help =~ s/<include\s+(\S+)>/inchelp($1)/ige;
48 # find and replace <if><else> directives
49 $help =~ s/<if\s+([^>]*)>([\000-\177]*?)<else>([\000-\177]*?)<\/if>/ifhelp($1, $2, $3)/ige;
51 # find and replace <if> directives
52 $help =~ s/<if\s+([^>]*)>([\000-\177]*?)<\/if>/ifhelp($1, $2)/ige;
54 # find and replace <exec> directives
55 $help =~ s/<exec\s+([^>]*)>/exechelp($1)/ige;
64 if ($_[0] =~ /^\/(\S+)\/(\S+)$/) {
65 # including something from another module..
68 # including from this module
69 local $ipath = &help_file($module, $_[0]);
72 return "<i>".&text('help_einclude', $_[0])."</i><br>\n";
73 read(INC, $inc, $st[7]);
79 # ifhelp(perl, text, [elsetext])
82 local $rv = eval $_[0];
83 if ($@) { return "<i>".&text('help_eif', $_[0], $@)."</i><br>\n"; }
84 elsif ($rv) { return $_[1]; }
85 else { return $_[2]; }
91 local $rv = eval $_[0];
92 if ($@) { return "<i>".&text('help_eexec', $_[0], $@)."</i><br>\n"; }
98 &header($text{'error'});
99 print "<center><h2>$text{'error'}</h2></center>\n";
100 print "<hr><p><b>",@_,"</b><p><hr>\n";