newnodelog.php3 2.17 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
Mike Hibler's avatar
Mike Hibler committed
3
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
23
#
24
include("defs.php3");
25
include_once("node_defs.php");
26 27

#
28
# Only known and logged in users.
29
#
30 31 32
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
33 34

#
35
# Verify page arguments.
36
#
37 38
$reqargs = RequiredPageArguments("node",      PAGEARG_NODE,
				 "log_type",  PAGEARG_STRING,
39
				 "log_entry", PAGEARG_ANYTHING);
40 41 42 43

#
# Only Admins can enter log entries.
#
44
if (! ($isadmin || OPSGUY())) {
45 46 47 48 49 50
    USERERROR("You do not have permission to enter log entries!", 1);
}

#
# Check log type. Strictly letters, not too long. 
#
Mike Hibler's avatar
Mike Hibler committed
51
if (!preg_match('/^[a-zA-Z]+$/', $log_type) || strlen($log_type) > 32) {
52 53 54
    USERERROR("The log type you gave looks funky!", 1);
}

55 56 57 58 59 60 61 62
# Anything allowed, but not too long.
if (! TBvalid_description($log_entry)) {
    USERERROR("Invalid log entry: " . TBFieldErrorString(), 1);
}

$log_type  = escapeshellarg($log_type);
$log_entry = escapeshellarg($log_entry);
$node_id   = $node->node_id();
63

64 65 66 67 68
#
# Standard Testbed Header
#
PAGEHEADER("Enter Node Log Entry");

69 70 71
#
# Run the external script. 
#
72 73
SUEXEC($uid, $TBADMINGROUP,
       "webnodelog -t $log_type -m $log_entry $node_id", 1);
74 75 76 77

#
# Show result.
# 
78
$node->ShowLog();
79 80 81 82

#
# New Entry option.
#
83
$url = CreateURL("newnodelog_form", $node);
84 85
echo "<p><center>
           Do you want to enter a log entry?
86
            <A href='$url'>Yes</a>
87 88 89 90 91 92 93
         </center>\n";

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