docwrapper.php3 1.43 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
Leigh Stoller's avatar
Leigh Stoller committed
5 6
# All rights reserved.
#
7 8 9 10
chdir("..");
require("defs.php3");
chdir("tutorial");

11 12 13 14 15 16 17 18 19 20 21 22
# Page arguments.
$printable = $_GET['printable'];
$docname   = $_GET['docname'];

# Pedantic page arument checking. Good practice!
if (!isset($docname) ||
    (isset($printable) && !($printable == "1" || $printable == "0"))) {
    PAGEARGERROR();
}
if (!isset($printable))
    $printable = 0;

23 24 25 26 27 28 29 30 31 32 33 34 35 36
#
# Standard Testbed Header
#
if (!$printable) {
    PAGEHEADER("Emulab Documentation");
}

#
# Need to sanity check the path! For now, just make sure the path
# does not start with a dot or a slash.
#
$first = substr($docname, 0, 1);
if (strcmp($first, ".") == 0 ||
    strcmp($first, "/") == 0) {
37
    USERERROR("Illegal document name: $docname!", 1);
38 39 40 41 42
}
#
# Nothing that looks like a ../ is allowed anywhere in the name
#
if (strstr($docname, "../")) {
43
    USERERROR("Illegal document name: $docname!", 1);
44 45
}

46 47 48 49 50 51 52 53 54 55 56
if ($printable) {
    #
    # Need to spit out some header stuff.
    #
    echo "<html>
          <head>
  	  <link rel='stylesheet' href='../tbstyle-plain.css' type='text/css'>
          </head>
          <body>\n";
}
else {
57
	echo "<b><a href=$REQUEST_URI&printable=1>
Leigh Stoller's avatar
Leigh Stoller committed
58
                 Printable version of this document</a></b><br>\n";
59 60 61 62 63 64 65
}

readfile("$docname");

#
# Standard Testbed Footer
# 
66 67 68 69 70
if ($printable) {
    echo "</body>
          </html>\n";
}
else {
71 72 73 74
    PAGEFOOTER();
}
?>