shownodehistory.php3 2.86 KB
Newer Older
1 2 3
<?php
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
5 6 7
# All rights reserved.
#
include("defs.php3");
8
include_once("node_defs.php");
9 10 11 12

#
# Only known and logged in users can do this.
#
13 14 15
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
16

17
if (! ($isadmin || OPSGUY() || STUDLY())) {
18 19 20 21
    USERERROR("Cannot view node history.", 1);
}

#
22 23 24 25 26
# Verify page arguments.
#
$optargs = OptionalPageArguments("showall",   PAGEARG_BOOLEAN,
				 "reverse",   PAGEARG_BOOLEAN,
				 "count",     PAGEARG_INTEGER,
27
				 "datetime",  PAGEARG_STRING,
28
				 "IP",        PAGEARG_STRING,
29 30
				 "node",      PAGEARG_NODE);

31 32 33 34 35
#
# Standard Testbed Header
#
PAGEHEADER("Node History");

36 37 38
if (!isset($showall)) {
    $showall = 0;
}
39 40 41 42 43 44
if (!isset($count)) {
    $count = 20;
}
if (!isset($reverse)) {
    $reverse = 1;
}
45 46 47
if (!isset($datetime)) {
    $datetime = "";
}
48 49 50 51 52 53
if (isset($IP)) {
    $node = Node::LookupByIP($IP);
    if (! $node) {
	USERERROR("Cannot map $IP to a node", 1);
    }
}
54
$node_id = (isset($node) ? $node->node_id() : "");
55

56
$opts="node_id=$node_id&count=$count&reverse=$reverse";
Mike Hibler's avatar
Mike Hibler committed
57
echo "<b>Show records:</b> ";
58 59 60 61 62 63 64 65 66
if ($showall) {
    echo "<a href='shownodehistory.php3?$opts'>allocated only</a>,
          all";
} else {
    echo "allocated only,
          <a href='shownodehistory.php3?$opts&showall=1'>all</a>";
}

$opts="node_id=$node_id&count=$count&showall=$showall";
Mike Hibler's avatar
Mike Hibler committed
67
echo "<br><b>Order by:</b> ";
68 69 70 71 72 73 74 75 76
if ($reverse == 0) {
    echo "<a href='shownodehistory.php3?$opts&reverse=1'>lastest first</a>,
          earliest first";
} else {
    echo "lastest first,
          <a href='shownodehistory.php3?$opts&reverse=0'>earliest first</a>";
}

$opts="node_id=$node_id&showall=$showall&reverse=$reverse";
Mike Hibler's avatar
Mike Hibler committed
77
echo "<br><b>Show number:</b> ";
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
if ($count != 20) {
    echo "<a href='shownodehistory.php3?$opts&count=20'>first 20</a>, ";
} else {
    echo "first 20, ";
}
if ($count != -20) {
    echo "<a href='shownodehistory.php3?$opts&count=-20'>last 20</a>, ";
} else {
    echo "last 20, ";
}
if ($count != 0) {
    echo "<a href='shownodehistory.php3?$opts&count=0'>all</a>";
} else {
    echo "all";
}
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
#
# Spit out a date form.
#
if ($datetime == "") {
    $datetime = "mm/dd/yy HH:MM";
}
if ($node_id != "") {
    echo "<br>";
    echo "<form action=shownodehistory.php3?$opts method=post>
      <b>Show Datetime:</b> 
      <input type=text
             name=datetime
             size=20
             value=\"$datetime\">
      <b><input type=submit name=search value=Search></b>\n";
    echo "</form><br><br>\n";
}

if ($node_id != "" && $datetime != "" && $datetime != "mm/dd/yy HH:MM") {
    if (strtotime($datetime)) {
	ShowNodeHistory($node, 1, 1, 0, $datetime);
    }
    else {
	USERERROR("Invalid date specified", 1);
    }
}
else {
    ShowNodeHistory((isset($node) ? $node : null), $showall, $count, $reverse);
}
123 124 125 126 127 128

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>