<commit_before><?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002, 2004 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include("showstuff.php3");

#
# Standard Testbed Header
#
PAGEHEADER("Node Control Form");

#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
# Check to make sure that this is a valid nodeid
#
$query_result =
    DBQueryFatal("SELECT * FROM nodes WHERE node_id='$node_id'");
if (mysql_num_rows($query_result) == 0) {
    USERERROR("The node $node_id is not a valid nodeid!", 1);
}
$row = mysql_fetch_array($query_result);

#
# Admin users can control any node, but normal users can only control
# nodes in their own experiments.
#
$isadmin = ISADMIN($uid);
if (! $isadmin) {
    if (! TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_MODIFYINFO)) {
        USERERROR("You do not have permission to modify node $node_id!", 1);
    }
}

#
# Check each parameter. Also note that when setting/clearing values,
# send the argument to the backend script *only when changed*
#
$command_string = "";

if ($def_boot_osid != $row[def_boot_osid]) {
    $command_string .= "default_boot_osid='$def_boot_osid' ";
}
if ($def_boot_cmd_line != $row[def_boot_cmd_line]) {
    $command_string .= "default_boot_cmdline='$def_boot_cmd_line' ";
}
if ($startupcmd != $row[startupcmd]) {
    $command_string .= "startup_command='$startupcmd' ";
}
if ($tarballs != $row[tarballs]) {
    $command_string .= "tarfiles='$tarballs' ";
}
if ($rpms != $row[rpms]) {
    $command_string .= "rpms='$rpms' ";
}

if ($isadmin) {
    if ($next_boot_osid != $row[next_boot_osid]) {
	$command_string .= "next_boot_osid='$next_boot_osid' ";
    }
    if ($next_boot_cmd_line != $row[next_boot_cmd_line]) {
	$command_string .= "next_boot_cmdline='$next_boot_cmd_line' ";
    }
    if ($temp_boot_osid != $row[temp_boot_osid]) {
	$command_string .= "temp_boot_osid='$temp_boot_osid' ";
    }
}

#
# Pass it off to the script.
#
SUEXEC($uid, "nobody", "webnodecontrol $command_string $node_id", 1);

echo "<center>
      <br>
      <h3>Node parameters successfully modified!</h3><p>
      </center>\n";

SHOWNODE($node_id);

#
# Edit option.
#
echo "<br><center>
           <A href='nodecontrol_form.php3?node_id=$node_id'>
           Edit this the node info?</a>
         </center>\n";

#
# Standard Testbed Footer<commit_msg>Minor (very minor!) cleanup.<commit_after><?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002, 2004 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include("showstuff.php3");

#
# Standard Testbed Header
#
PAGEHEADER("Node Control Form");

#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
# Check to make sure that this is a valid nodeid
#
$query_result =
    DBQueryFatal("SELECT * FROM nodes WHERE node_id='$node_id'");
if (mysql_num_rows($query_result) == 0) {
    USERERROR("The node $node_id is not a valid nodeid!", 1);
}
$row = mysql_fetch_array($query_result);

#
# Admin users can control any node, but normal users can only control
# nodes in their own experiments.
#
$isadmin = ISADMIN($uid);
if (! $isadmin) {
    if (! TBNodeAccessCheck($uid, $node_id, $TB_NODEACCESS_MODIFYINFO)) {
        USERERROR("You do not have permission to modify node $node_id!", 1);
    }
}

#
# Check each parameter. Also note that when setting/clearing values,
# send the argument to the backend script *only when changed*
#
$command_string = "";

if ($def_boot_osid != $row[def_boot_osid]) {
    $command_string .= "default_boot_osid='$def_boot_osid' ";
}
if ($def_boot_cmd_line != $row[def_boot_cmd_line]) {
    $command_string .= "default_boot_cmdline='$def_boot_cmd_line' ";
}
if ($startupcmd != $row[startupcmd]) {
    $command_string .= "startup_command='$startupcmd' ";
}
if ($tarballs != $row[tarballs]) {
    $command_string .= "tarfiles='$tarballs' ";
}
if ($rpms != $row[rpms]) {
    $command_string .= "rpms='$rpms' ";
}

if ($isadmin) {
    if ($next_boot_osid != $row[next_boot_osid]) {
	$command_string .= "next_boot_osid='$next_boot_osid' ";
    }
    if ($next_boot_cmd_line != $row[next_boot_cmd_line]) {
	$command_string .= "next_boot_cmdline='$next_boot_cmd_line' ";
    }
    if ($temp_boot_osid != $row[temp_boot_osid]) {
	$command_string .= "temp_boot_osid='$temp_boot_osid' ";
    }
}

#
# Pass it off to the script. It will check the arguments.
#
SUEXEC($uid, "nobody", "webnodecontrol $command_string $node_id",
       SUEXEC_ACTION_DIE);

echo "<center>
      <br>
      <h3>Node parameters successfully modified!</h3><p>
      </center>\n";

SHOWNODE($node_id);

#
# Edit option.
#
echo "<br><center>
           <A href='nodecontrol_form.php3?node_id=$node_id'>
           Edit this the node info?</a>
         </center>\n";

#
# Standard Testbed Footer
{'fraction_non_alphanumeric': 0.15583075335397317, 'fraction_numerical': 0.00846233230134159, 'mean_word_length': 4.3370044052863435, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '729061', 'n_tokens_mistral': 1806, 'n_tokens_neox': 1756, 'n_words': 405}