newnodelog.php3 1.71 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2 3 4 5 6
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
include("defs.php3");
include("showstuff.php3");

#
# Standard Testbed Header
#
PAGEHEADER("Enter Node Log Entry");

#
# Only known and logged in users can create an OSID.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);

#
# First off, sanity check the form to make sure all the required fields
# were provided. I do this on a per field basis so that we can be
# informative. Be sure to correlate these checks with any changes made to
# the project form. 
#
if (!isset($node_id) ||
    strcmp($node_id, "") == 0) {
  FORMERROR("Node ID");
}
if (!isset($log_type) ||
    strcmp($log_type, "") == 0) {
  FORMERROR("Log Type");
}
if (!isset($log_entry) ||
    strcmp($log_entry, "") == 0) {
  FORMERROR("Log Entry");
}

#
# Only Admins can enter log entries.
#
if (! $isadmin) {
    USERERROR("You do not have permission to enter log entries!", 1);
}

#
# Check to make sure that this is a valid nodeid
#
if (! TBValidNodeName($node_id)) {
    USERERROR("The node $node_id is not a valid nodeid!", 1);
}

#
# Check log type. Strictly letters, not too long. 
#
if (! ereg("^[a-zA-Z]+$", $log_type) || strlen($log_type) > 32) {
    USERERROR("The log type you gave looks funky!", 1);
}

$log_entry = addslashes($log_entry);

#
# Run the external script. 
#
67
SUEXEC($uid, $TBADMINGROUP, "webnodelog -t $log_type -m \"$log_entry\" $node_id", 1);
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

#
# Show result.
# 
SHOWNODELOG($node_id);

#
# New Entry option.
#
echo "<p><center>
           Do you want to enter a log entry?
           <A href='newnodelog_form.php3?node_id=$node_id'>Yes</a>
         </center>\n";

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