" . $addr . ""; } function pg_email() { mlink("proofgen@dcs.ed.ac.uk"); } /* Style sheet element for dt doesnt work in Netscape, so hack it here. */ function dt($string) { print "
"; print $string; print "
"; } /* Automatic footnotes! */ /* FIXME: for now, do nothing. */ function footnote ($text) { print "

[" . $text . "]

"; } /* A hyper-link with optional mouse over text. Could be made more sophisticated to do roll-overs, or whatever. */ function hlink ($url,$text,$mouseover="") { print "" . $text . ""; } /* Determining download sizes (print broken message if file not found) */ function download_size($filename) { if (file_exists($filename)) { $size = filesize($filename); $sizek = (int) ($size/1024); print " ("; if ($sizek == 0) { print $size . " bytes)"; } else { print $sizek . "k)"; } } else { print " (link broken)"; } } function download_link($filename,$linkname = "") { print ""; if ($linkname == "") { print $filename; } else { print $linkname; }; print ""; print download_size($filename); } function date_modified($filename) { $time = filemtime($filename); if ($time) { print "Last modified " . strftime("%d %B %Y",$time) . ".\n"; } } /* Nav bar separator */ $separator = ' . '; /* A link to one of the main pages (must appear in navbar menu) */ function link_root($page,$text) { print ""; print $text; print "\n"; } function small_header($title) { include('smallheader.phtml'); print "

" . $title . "

\n\n\n"; } function footer($filemodified=".") { include('footer.phtml'); date_modified($filemodified); print "\n"; print "\n\n"; } function click_to_go_back() { print "

\nClick here to go back to the Proof General front page.

\n"; } /* Link to a marked up file */ /* NB: could determine type automatically! */ function fileshow($filename,$text="",$title="") { if ( $text == "") { $text=$filename; }; $message=$title; if ( $message == "") { $message=$filename; }; hlink("fileshow.phtml?file=" . urlencode($filename) . "&title=" . urlencode($title), $text, $message); } /* Similar for html file (NB: could pick automatically) */ function htmlshow($filename,$text="",$title="") { if ( $text == "") { $text=$filename; }; $message=$title; $urlbits = parse_url($filename); if ( $message == "") { $message=$filename; }; hlink("htmlshow.phtml?file=" . urlencode($urlbits["path"]) . "&title=" . urlencode($title) . ($urlbits["fragment"]=="" ? "" : "#" . $urlbits["fragment"]), $text, $message); } /* Markup plain text file, by escaping < and > */ function markup_plain_text($filename) { $file = file($filename); for($i = 0;$i < count($file);$i++) { $line = $file[$i]; $line = ereg_replace("<","<",$line); $line = ereg_replace(">",">",$line); print $line; }; } /* Hack an html file to be shown with our style sheet and hack relative links to go via htmlshow.phtml. This isn't particularly robust, but seems to work for the output of texi2html. */ function hack_html($filename,$title="") { if ($title=="") { $title=$filename; }; $file = file($filename); /* Paste style sheet in head */ for($i = 0;$i < count($file);$i++) { $line = $file[$i]; if (eregi("",$line)) { /* Paste in style sheet */ print "\n"; /* End style sheet paste in */ print $line; break; } else { print $line; }; } /* Now parse rest of document, hacking relative links. */ /* Matching here is not great, will get confused by html tags inside strings, etc. */ for (;$i < count($file);$i++) { $line = $file[$i]; /* PHP has no way to get the match position, so we have to match a suffix of the line, add extra parenthesis, and calculate it. */ while (eregi("(]*)(HREF=\"([^\"]+)\")(.*))",$line,$linebits)) { /* found URL in a particularly simple form */ $matchpos = strlen($line) - strlen($linebits[1]); print substr($line,0,$matchpos); /* start of line */ $line = $linebits[5]; /* rest of line after link */ $urlbits = parse_url($linebits[4]); if ($urlbits["host"]=="") { /* Assume a relative link, let's hack it. */ $newurl = "htmlshow.phtml?file=" . urlencode(dirname($filename)) . "/" . $urlbits["path"] . ($urlbits["fragment"]=="" ? "" : "#" . $urlbits["fragment"]); print "",$line)) { /* Assume there's nothing else interesting on the line, whoops. */ small_header(""); print $line; } elseif (eregi("",$line)) { /* Assume there's nothing else interesting on the line, whoops. */ click_to_go_back(); print $line; } else { print $line; }; } }