3 # Displays help HTML for some module, with substitutions
5 require './web-lib.pl';
7 &error_setup($text{'help_err'});
8 $ENV{'PATH_INFO'} !~ /[\\\&\;\`\'\"\|\*\?\~\<\>\^\(\)\[\]\{\}\$\n\r]/ ||
9 &error($text{'help_epath'});
10 $ENV{'PATH_INFO'} =~ /^\/(\S+)\/(\S+)$/ || &error($text{'help_epath'});
11 $module = $1; $file = $2;
13 # if it ends with .gif assume it is a direct URL
14 if ($file =~ /\.(gif|jpg|jpeg|png)$/i) {
15 &redirect("$module/$file");
20 $path = &help_file($module, $file);
22 open(HELP, $path) || &helperror(&text('help_efile', $path));
23 read(HELP, $help, $st[7]);
26 # find and replace the <header> section
27 if ($help =~ s/<header>([^<]+)<\/header>/<center><h3>$1<\/h3><\/center><hr>/i) {
31 &helperror($text{'help_eheader'});
34 # find and replace the <footer> section
35 $help =~ s/<footer>/<p><hr>/i;
37 # find and replace <include> directives
38 $help =~ s/<include\s+(\S+)>/inchelp($1)/ige;
40 # find and replace <if><else> directives
41 $help =~ s/<if\s+([^>]*)>([\000-\177]*?)<else>([\000-\177]*?)<\/if>/ifhelp($1, $2, $3)/ige;
43 # find and replace <if> directives
44 $help =~ s/<if\s+([^>]*)>([\000-\177]*?)<\/if>/ifhelp($1, $2)/ige;
46 # find and replace <exec> directives
47 $help =~ s/<exec\s+([^>]*)>/exechelp($1)/ige;
56 if ($_[0] =~ /^\/(\S+)\/(\S+)$/) {
57 # including something from another module..
60 # including from this module
61 local $ipath = &help_file($module, $_[0]);
64 return "<i>".&text('help_einclude', $_[0])."</i><br>\n";
65 read(INC, $inc, $st[7]);
71 # ifhelp(perl, text, [elsetext])
74 local $rv = eval $_[0];
75 if ($@) { return "<i>".&text('help_eif', $_[0], $@)."</i><br>\n"; }
76 elsif ($rv) { return $_[1]; }
77 else { return $_[2]; }
83 local $rv = eval $_[0];
84 if ($@) { return "<i>".&text('help_eexec', $_[0], $@)."</i><br>\n"; }
90 &header($text{'error'});
91 print "<center><h2>$text{'error'}</h2></center>\n";
92 print "<hr><p><b>",@_,"</b><p><hr>\n";