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

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

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

#
# Verify page arguments.
#
$optargs = OptionalPageArguments("showall",   PAGEARG_BOOLEAN,
				 "datetime",  PAGEARG_STRING,
				 "record",    PAGEARG_INTEGER,
				 "count",     PAGEARG_INTEGER,
				 "when",      PAGEARG_STRING,
				 "IP",        PAGEARG_STRING,
				 "mac",       PAGEARG_STRING,
				 # To allow for pcvm search, since they are
                                 # transient and will not map to a node.
				 "node_id",   PAGEARG_STRING);

#
# Standard Testbed Header
#
PAGEHEADER("Node History");

if (!isset($showall)) {
    $showall = 0;
}
if (!isset($count)) {
    $count = 200;
}
if (!isset($record) || $record == "") {
    $record = null;
}
if (isset($record)) {
    # Record overrides date/when.
    $dateopt  = "";
    $datetime = null;
    $when     = null;
}
elseif (isset($datetime) && $datetime != "") {
    if (! strtotime($datetime)) {
	USERERROR("Invalid date specified", 1);
    }
    $dateopt = "&datetime=" . urlencode($datetime);
    $record  = null;
}
elseif (isset($when) && $when == "yesterday") {
    $datetime = date("Y-m-d H:i:s", time() - (24 * 3600));
    $dateopt = "&datetime=" . urlencode($datetime);
    $record  = null;
}
elseif (isset($when) && $when == "lastweek") {
    $datetime = date("Y-m-d H:i:s", time() - (7 * 24 * 3600));
    $dateopt = "&datetime=" . urlencode($datetime);
    $record  = null;
}
elseif (isset($when) && $when == "lastmonth") {
    $datetime = date("Y-m-d H:i:s", time() - (30 * 24 * 3600));
    $dateopt = "&datetime=" . urlencode($datetime);
    $record  = null;
}
else {
    $dateopt  = "";
    $datetime = null;
    $when     = "epoch";
}
if (isset($IP)) {
    if (! preg_match('/^[0-9\.]+$/', $IP)) {    
	USERERROR("Does not look like a valid IP address.", 1);
    }
    $node = Node::LookupByIP($IP);

    #
    # Switch to a node_id if its a physical node. Otherwise, 
    # continue with the IP.
    #
    if ($node && !$node->IsVirtNode()) {
	$node_id = $node->node_id();
	$IP = null;
    }
}
else {
    $IP = null;
}
if (isset($mac)) {
    if (! preg_match('/^[\w\:]+$/', $mac)) {    
	USERERROR("Does not look like a valid mac address.", 1);<commit_msg>Minor bug fix for public IP search.<commit_after><?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include_once("node_defs.php");

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

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

#
# Verify page arguments.
#
$optargs = OptionalPageArguments("showall",   PAGEARG_BOOLEAN,
				 "datetime",  PAGEARG_STRING,
				 "record",    PAGEARG_INTEGER,
				 "count",     PAGEARG_INTEGER,
				 "when",      PAGEARG_STRING,
				 "IP",        PAGEARG_STRING,
				 "mac",       PAGEARG_STRING,
				 # To allow for pcvm search, since they are
                                 # transient and will not map to a node.
				 "node_id",   PAGEARG_STRING);

#
# Standard Testbed Header
#
PAGEHEADER("Node History");

if (!isset($showall)) {
    $showall = 0;
}
if (!isset($count)) {
    $count = 200;
}
if (!isset($record) || $record == "") {
    $record = null;
}
if (isset($record)) {
    # Record overrides date/when.
    $dateopt  = "";
    $datetime = null;
    $when     = null;
}
elseif (isset($datetime) && $datetime != "") {
    if (! strtotime($datetime)) {
	USERERROR("Invalid date specified", 1);
    }
    $dateopt = "&datetime=" . urlencode($datetime);
    $record  = null;
}
elseif (isset($when) && $when == "yesterday") {
    $datetime = date("Y-m-d H:i:s", time() - (24 * 3600));
    $dateopt = "&datetime=" . urlencode($datetime);
    $record  = null;
}
elseif (isset($when) && $when == "lastweek") {
    $datetime = date("Y-m-d H:i:s", time() - (7 * 24 * 3600));
    $dateopt = "&datetime=" . urlencode($datetime);
    $record  = null;
}
elseif (isset($when) && $when == "lastmonth") {
    $datetime = date("Y-m-d H:i:s", time() - (30 * 24 * 3600));
    $dateopt = "&datetime=" . urlencode($datetime);
    $record  = null;
}
else {
    $dateopt  = "";
    $datetime = null;
    $when     = "epoch";
}
if (isset($IP)) {
    if (! preg_match('/^[0-9\.]+$/', $IP)) {    
	USERERROR("Does not look like a valid IP address.", 1);
    }
}
else {
    $IP = null;
}
if (isset($mac)) {
    if (! preg_match('/^[\w\:]+$/', $mac)) {    
	USERERROR("Does not look like a valid mac address.", 1);
{'fraction_non_alphanumeric': 0.19389002036659878, 'fraction_numerical': 0.016293279022403257, 'mean_word_length': 2.8699763593380614, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3710457', 'n_tokens_mistral': 1854, 'n_tokens_neox': 1733, 'n_words': 434}