]> i-scream Git - www.i-scream.org.git/blobdiff - cgi-bin/docs.cgi
Display a different logo if coming in from IPv6. It's not nice, but I don't
[www.i-scream.org.git] / cgi-bin / docs.cgi
index 402c9e505ba29cb49bd023f9ed76ce1ed741b7ca..91e99f009a74f9c0ac06355cd8924c3256b6e413 100755 (executable)
@@ -6,10 +6,14 @@ use CGI;
 $| = 1;
 
 # Settings
-my ($menu) = "../nwww/menu.inc" ;
-my ($header) = "../nwww/header.inc";
-my ($footer) = "../nwww/footer.inc";
-my ($style) = "../nwww/style.inc";
+my ($incdir) = "../htdocs";
+
+# Include files
+my ($doctype) = "$incdir/doctype.inc";
+my ($style) = "$incdir/style.inc";
+my ($header) = "$incdir/header.inc";
+my ($footer) = "$incdir/footer.inc";
+my ($menu) = "$incdir/menu-static.inc" ;
 
 my ($query) = new CGI;
 
@@ -17,6 +21,7 @@ my ($query) = new CGI;
 # This prevents malicious users using "../" to view files.
 my ($doc) = ($query->param('doc') =~ /^\s*([^\.]*?\.txt)\s*$/);
 
+# This should be application/xhtml+xml
 print "Content-type: text/html\n\n";
 
 unless (defined $doc) {
@@ -30,61 +35,70 @@ unless ($doc =~ /^[a-zA-Z_\-0-9\.\/]+$/) {
     print "Malformed request.";
     exit;
 }
-$doc = "../htdocs/documentation/".$doc;
+$doc = "../htdocs/cms/documentation/".$doc;
 
 my($docname) = $doc =~ /\/([^\/]+)$/;
 
-print <<"END";
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+&print_html($doctype);
 
-<html>
+print <<"END";
 
-<head>
- <title>i-scream plain text documentation viewer</title>
+  <head>
+    <title>
+      i-scream plain text documentation viewer
+    </title>
 END
 
 &print_html($style);
 
 print <<"END";
-</head>
-
-<body>
-
-<div id="container">
 
-<div id="main">
+  </head>
+  <body>
+    <div id="container">
+      <div id="main">
 END
 
 &print_html($header);
 
 print <<"END";
-<div id="contents">
-<h1 class="top">i-scream documentation viewer</h1>
 
-<h2>$docname</h2>
+        <div id="contents">
+          <h1 class="top">
+            i-scream documentation viewer
+          </h1>
+          <h2>
+            $docname
+          </h2>
 END
 
 &print_file($doc);
-print "</div>";
+
+print <<"END";
+
+        </div>
+END
 
 &print_html($footer);
 
-print "</div>";
+print <<"END";
+
+      </div>
+END
 
 &print_html($menu);
 
 print <<"END";
-</div>
 
-</body>
+    </div>
+  </body>
 </html>
 END
 
 exit 0;
 
 # Print a file, whilst escaping HTML: -
-sub print_file ($) {
+sub print_file {
 my ($urls) = '(' . join ('|', qw{
               http
               telnet
@@ -95,32 +109,36 @@ my ($urls) = '(' . join ('|', qw{
               } )
           . ')';
 
-my ($ltrs) = '\w';
-my ($gunk) = '/#~:.?+=&%@!\-';
-my ($punc) = '.:?\-';
-my ($any) = "${ltrs}${gunk}${punc}";
-my ($filename) = @_;
-if(open(FILE, $filename)) {
-    print "<pre>\n";
-    # Use $_ implicitly throughout.
-    while (<FILE>) {
-        # Must do the next line first!
-        s/&/&amp;/g;
-        s/</&lt;/g;
-        s/>/&gt;/g;
-        s/"/&quot;/g;
-        s/\b($urls:[$any]+?)(?=[$punc]*[^$any]|$)/<a href="$1">$1<\/a>/igox;
-        print;
+    my ($ltrs) = '\w';
+    my ($gunk) = '/#~:.?+=&%@!\-';
+    my ($punc) = '.:?\-';
+    my ($any) = "${ltrs}${gunk}${punc}";
+    my ($filename) = @_;
+    if(open(FILE, $filename)) {
+        print "          <pre>\n";
+        # Use $_ implicitly throughout.
+        while (<FILE>) {
+            # Must do the next line first!
+            s/&/&amp;/g;
+            s/</&lt;/g;
+            s/>/&gt;/g;
+            s/"/&quot;/g;
+            s/\b($urls:[$any]+?)(?=[$punc]*[^$any]|$)/<a href="$1">$1<\/a>/igox;
+            print;
+        }
+        print "\n</pre>";
+    }
+    else {
+        print "Failed to open $docname.";
     }
-    print "</pre>";
-}
-else {
-    print "Failed to open $docname.";
-}
 }
 
-# Print a file without escaping HTML: -
+# Print the contents of a file containing html
 sub print_html ($) {
-my ($filename) = @_;
-print `cat $filename 2>&1`;
+    my ($filename) = @_;
+    open(FILE, $filename);
+    while(<FILE>) {
+        print;
+    }
+    close FILE;
 }