| 6 |  | $| = 1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 7 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 8 |  | # Settings | 
 
 
 
 
 
 
 
 
 
 
 | 9 | < | my ($incdir) = "../nwww"; | 
 
 
 
 
 
 
 
 
 | 9 | > | my ($incdir) = "../htdocs"; | 
 
 
 
 
 
 
 
 
 
 
 | 10 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 11 |  | # Include files | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 12 |  | my ($doctype) = "$incdir/doctype.inc"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 13 |  | my ($style) = "$incdir/style.inc"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 14 |  | my ($header) = "$incdir/header.inc"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 15 |  | my ($footer) = "$incdir/footer.inc"; | 
 
 
 
 
 
 
 
 
 
 
 | 16 | < | my ($menu) = "$incdir/menu.inc" ; | 
 
 
 
 
 
 
 
 
 | 16 | > | my ($menu) = "$incdir/menu-static.inc" ; | 
 
 
 
 
 
 
 
 
 
 
 | 17 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 18 |  | my ($query) = new CGI; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 19 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 98 |  | exit 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 99 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 100 |  | # Print a file, whilst escaping HTML: - | 
 
 
 
 
 
 
 
 
 
 
 | 101 | < | sub print_file ($) { | 
 
 
 
 
 
 
 
 
 | 101 | > | sub print_file { | 
 
 
 
 
 
 
 
 
 
 
 | 102 |  | my ($urls) = '(' . join ('|', qw{ | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 103 |  | http | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 104 |  | telnet | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 109 |  | } ) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 110 |  | . ')'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 111 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 112 | < | my ($ltrs) = '\w'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 113 | < | my ($gunk) = '/#~:.?+=&%@!\-'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 114 | < | my ($punc) = '.:?\-'; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 115 | < | my ($any) = "${ltrs}${gunk}${punc}"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 116 | < | my ($filename) = @_; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 117 | < | if(open(FILE, $filename)) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 118 | < | print "          <pre>\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 119 | < | # Use $_ implicitly throughout. | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 120 | < | while (<FILE>) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 121 | < | # Must do the next line first! | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 122 | < | s/&/&/g; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 123 | < | s/</</g; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 124 | < | s/>/>/g; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 125 | < | s/"/"/g; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 126 | < | s/\b($urls:[$any]+?)(?=[$punc]*[^$any]|$)/<a href="$1">$1<\/a>/igox; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 127 | < | print; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 112 | > | my ($ltrs) = '\w'; | 
 
 
 
 
 | 113 | > | my ($gunk) = '/#~:.?+=&%@!\-'; | 
 
 
 
 
 | 114 | > | my ($punc) = '.:?\-'; | 
 
 
 
 
 | 115 | > | my ($any) = "${ltrs}${gunk}${punc}"; | 
 
 
 
 
 | 116 | > | my ($filename) = @_; | 
 
 
 
 
 | 117 | > | if(open(FILE, $filename)) { | 
 
 
 
 
 | 118 | > | print "          <pre>\n"; | 
 
 
 
 
 | 119 | > | # Use $_ implicitly throughout. | 
 
 
 
 
 | 120 | > | while (<FILE>) { | 
 
 
 
 
 | 121 | > | # Must do the next line first! | 
 
 
 
 
 | 122 | > | s/&/&/g; | 
 
 
 
 
 | 123 | > | s/</</g; | 
 
 
 
 
 | 124 | > | s/>/>/g; | 
 
 
 
 
 | 125 | > | s/"/"/g; | 
 
 
 
 
 | 126 | > | s/\b($urls:[$any]+?)(?=[$punc]*[^$any]|$)/<a href="$1">$1<\/a>/igox; | 
 
 
 
 
 | 127 | > | print; | 
 
 
 
 
 | 128 | > | } | 
 
 
 
 
 | 129 | > | print "\n</pre>"; | 
 
 
 
 
 
 
 
 
 
 
 | 130 |  | } | 
 
 
 
 
 
 
 
 
 
 
 | 131 | < | print "\n</pre>"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 131 | > | else { | 
 
 
 
 
 | 132 | > | print "Failed to open $docname."; | 
 
 
 
 
 | 133 | > | } | 
 
 
 
 
 
 
 
 
 
 
 | 134 |  | } | 
 
 
 
 
 
 
 
 
 | 131 | – | else { | 
 
 
 
 
 
 
 
 
 | 132 | – | print "Failed to open $docname."; | 
 
 
 
 
 
 
 
 
 | 133 | – | } | 
 
 
 
 
 
 
 
 
 | 134 | – | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 135 |  |  | 
 
 
 
 
 
 
 
 
 
 
 | 136 | < | # Print a file without escaping HTML: - | 
 
 
 
 
 
 
 
 
 | 136 | > | # Print the contents of a file containing html | 
 
 
 
 
 
 
 
 
 
 
 | 137 |  | sub print_html ($) { | 
 
 
 
 
 
 
 
 
 
 
 | 138 | < | my ($filename) = @_; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 139 | < | print `cat $filename 2>&1`; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 138 | > | my ($filename) = @_; | 
 
 
 
 
 | 139 | > | open(FILE, $filename); | 
 
 
 
 
 | 140 | > | while(<FILE>) { | 
 
 
 
 
 | 141 | > | print; | 
 
 
 
 
 | 142 | > | } | 
 
 
 
 
 | 143 | > | close FILE; | 
 
 
 
 
 
 
 
 
 
 
 | 144 |  | } |