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

11
12
13
14
# Page arguments.
$printable = $_GET['printable'];
$docname   = $_GET['docname'];

Leigh B. Stoller's avatar
Leigh B. Stoller committed
15
# Pedantic page argument checking. Good practice!
16
17
18
19
20
21
22
if (!isset($docname) ||
    (isset($printable) && !($printable == "1" || $printable == "0"))) {
    PAGEARGERROR();
}
if (!isset($printable))
    $printable = 0;

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

#
31
# Need to sanity check the path! Allow only [word].html files
32
#
33
if (!preg_match("/^[-\w]+\.(html|txt)$/", $docname)) {
34
    USERERROR("Illegal document name: $docname!", 1);
35
36
}

37
38
39
40
41
42
43
44
45
46
47
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 {
48
	echo "<b><a href=$REQUEST_URI&printable=1>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
49
                 Printable version of this document</a></b><br>\n";
50
51
52
53
54
55
56
}

readfile("$docname");

#
# Standard Testbed Footer
# 
57
58
59
60
61
if ($printable) {
    echo "</body>
          </html>\n";
}
else {
62
63
64
65
    PAGEFOOTER();
}
?>