Diff for /loncom/interface/lonhelp.pm between versions 1.3 and 1.6

version 1.3, 2002/07/26 19:58:52 version 1.6, 2003/07/15 18:50:43
Line 31  package Apache::lonhelp; Line 31  package Apache::lonhelp;
   
 use strict;  use strict;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Apache::File;  use Apache::File();
 use Apache::loncommon;  use Apache::loncommon();
 use tth;  use Apache::lonacc();
 use GDBM_File;  use Apache::lontexconvert();
   use tth();
   use GDBM_File();
   
 # This sub takes the name of a label in, and converts it to something  # This sub takes the name of a label in, and converts it to something
 # that is a valid anchor name.  # that is a valid anchor name.
Line 56  $r->print(<<HEADER); Line 58  $r->print(<<HEADER);
         <title>LON-CAPA Help</title>          <title>LON-CAPA Help</title>
     </head>      </head>
     <body bgcolor="#FFFFFF">      <body bgcolor="#FFFFFF">
       <h3 style="font: sans-serif"><img align="right"
       src="/adm/help/gif/lonhelpheader.gif"/>LON-CAPA Help<hr /></h3>
     <!-- BEGIN -->      <!-- BEGIN -->
 HEADER  HEADER
   
Line 63  HEADER Line 67  HEADER
   
 $r->print(<<FOOTER);  $r->print(<<FOOTER);
     <!-- END -->      <!-- END -->
       <hr />
       <center><font size="-1"><a href="/adm/help/abouthelp.html">About
       LON-CAPA help and More Help</a></font></center>
     </body>      </body>
 </html>  </html>
 FOOTER  FOOTER
Line 99  sub render Line 106  sub render
                 ' bordercolor="#000000"/>\\end{html}'                  ' bordercolor="#000000"/>\\end{html}'
              |gxe;               |gxe;
   
     $tex = tth::tth($tex);  
   
       $tex=&Apache::lontexconvert::converted(\$tex);
       
     # Finish backslashes      # Finish backslashes
     $tex =~ s/###BACKSLASH###/'\\'/ge;      $tex =~ s/###BACKSLASH###/'\\'/ge;
     
Line 111  sub render Line 119  sub render
     # just duck the issue...      # just duck the issue...
   
     $tex =~ s/Figure 0://g;      $tex =~ s/Figure 0://g;
        $tex.=$Apache::lontexconvert::errorstring;
     untie %fragmentLabels;      untie %fragmentLabels;
   
     return $tex;      return $tex;
Line 124  sub handler Line 132  sub handler
      my $docroot = $r->dir_config('lonDocRoot');       my $docroot = $r->dir_config('lonDocRoot');
      my $serverroot = $ENV{'HTTP_HOST'};       my $serverroot = $ENV{'HTTP_HOST'};
   
      my $filename = substr ($ENV{'REQUEST_URI'} ,        my $filenames = substr ($ENV{'REQUEST_URI'} , 
     rindex($ENV{'REQUEST_URI'}, '/') + 1, -4);      rindex($ENV{'REQUEST_URI'}, '/') + 1, -4);
             
      # Security check on the file; the whole filename must consist       # Security check on the file; the whole filename must consist
      # of nothing but alphanums, ' ,, or ., or the file       # of nothing but alphanums, ' ,, or ., or the file
      # will be "not found", no matter what.       # will be "not found", no matter what.
             
      return 404 if ($filename !~ /\A[-0-9a-zA-z_'',.]+\Z/);       return HTTP_NOT_FOUND if ($filenames !~ /\A[-0-9a-zA-z_'',.]+\Z/);
   
        # Join together the tex files, return HTTP_NOT_FOUND if any of
        # them are not found
        my $tex = '';
        my @files = split(/,/, $filenames);
        
        for my $filename (@files) {
    (my $file = Apache::File->new($docroot
      . '/adm/help/tex/'.$filename.'.tex'))
        or return HTTP_NOT_FOUND;
    $tex .= join('', <$file>);
        }
   
        # get me my environment if it exists
        &Apache::lonacc::handler($r);
   
        if ($ENV{'browser.mathml'}) {
    $r->content_type('text/xml');
    &tth::ttminit();
    if ($ENV{'browser.unicode'}) {
        &tth::ttmoptions('-L -u1');
    } else {
        &tth::ttmoptions('-L -u0');
    }
        } else {
    $r->content_type("text/html");
    &tth::tthinit();
    if ($ENV{'browser.unicode'}) {
        &tth::tthoptions('-L -u1');
    } else {
        &tth::tthoptions('-L -u0');
    }
        }
   
      (my $file = Apache::File->new($docroot . "/adm/help/tex/".$filename.'.tex'))  
  or return 404;  
      my $tex = join('', <$file>);  
      $tex = render($tex, $docroot, $serverroot);       $tex = render($tex, $docroot, $serverroot);
      $r->content_type("text/html");  
      serveTex($tex, $r);       serveTex($tex, $r);
   
      return OK;       return OK;

Removed from v.1.3  
changed lines
  Added in v.1.6


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>