3 # Displays help HTML for some module, with substitutions
5 $trust_unknown_referers = 1;
6 require './web-lib.pl';
9 &error_setup($text{'help_err'});
10 $ENV{'PATH_INFO'} !~ /[\\\&\;\`\'\"\|\*\?\~\<\>\^\(\)\[\]\{\}\$\n\r]/ ||
11 &error($text{'help_epath'});
12 $ENV{'PATH_INFO'} =~ /^\/(\S+)\/(\S+)$/ || &error($text{'help_epath'});
13 $module = $1; $file = $2;
15 # if it ends with .gif assume it is a direct URL
16 if ($file =~ /\.(gif|jpg|jpeg|png)$/i) {
17 &redirect("$module/$file");
22 $path = &help_file($module, $file);
24 open(HELP, $path) || &helperror(&text('help_efile', $path));
25 read(HELP, $help, $st[7]);
28 # find and replace the <header> section
29 if ($help =~ s/<header>([^<]+)<\/header>//i) {
31 print &ui_subheading($1);
34 &helperror($text{'help_eheader'});
37 # replace any explicit use of <hr> with the ui-lib function
39 $help =~ s/<hr>/$uihr/ig;
41 # find and replace the <footer> section
42 $help =~ s/<footer>/<p>/i;
44 # find and replace <include> directives
45 $help =~ s/<include\s+(\S+)>/inchelp($1)/ige;
47 # find and replace <if><else> directives
48 $help =~ s/<if\s+([^>]*)>([\000-\177]*?)<else>([\000-\177]*?)<\/if>/ifhelp($1, $2, $3)/ige;
50 # find and replace <if> directives
51 $help =~ s/<if\s+([^>]*)>([\000-\177]*?)<\/if>/ifhelp($1, $2)/ige;
53 # find and replace <exec> directives
54 $help =~ s/<exec\s+([^>]*)>/exechelp($1)/ige;
63 if ($_[0] =~ /^\/(\S+)\/(\S+)$/) {
64 # including something from another module..
67 # including from this module
68 local $ipath = &help_file($module, $_[0]);
71 return "<i>".&text('help_einclude', $_[0])."</i><br>\n";
72 read(INC, $inc, $st[7]);
78 # ifhelp(perl, text, [elsetext])
81 local $rv = eval $_[0];
82 if ($@) { return "<i>".&text('help_eif', $_[0], $@)."</i><br>\n"; }
83 elsif ($rv) { return $_[1]; }
84 else { return $_[2]; }
90 local $rv = eval $_[0];
91 if ($@) { return "<i>".&text('help_eexec', $_[0], $@)."</i><br>\n"; }
97 &header($text{'error'});
98 print "<center><h2>$text{'error'}</h2></center>\n";
99 print "<hr><p><b>",@_,"</b><p><hr>\n";