<commit_before><?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#

chdir("..");
include("defs.php3");

# this is just saving data; it isnt human readable.

#
# Only known and logged in users can begin experiments.
#

if (isset($guid) && ereg("^[0-9]+$", $guid)) {
	$uid = $guid;
} else {
	if (isset($uid)) {
		$uid = GETLOGIN();
		LOGGEDINORDIE($uid);
	} else {
		USERERROR( "Need to send guid or uid!" );
        } 
}

if (!isset($nsdata)) {
	USERERROR( "Need to send NSFILE!" );
} 

if (!isset($nsref) || !ereg("^[0-9]+$", $nsref)) {
	USERERROR( "Need to send valid NSREF!" );
}

#if (isset($nsdata)) {
#    if (strcmp($nsdata, "") == 0) 
#	unset($nsdata);
#   elseif (! isset($submit))
# 	$nsdata = rawurlencode($nsdata);
#}

#$nsfile_safe = addslashes($nsdata);
#$nsref_safe = addslashes($nsref);

#DBQueryFatal("INSERT INTO nsfiles_transient ".
#	     "(nsfileid, time, uid, nsfile) ".
#	     "VALUES ('$nsref_safe', now(), '$uid', '$nsfile_safe') " );

#echo "INSERT INTO nsfiles_transient ".
#     "(nsfileid, time, uid, nsfile) ".
#     "VALUES ('$nsref_safe', now(), '$uid', '$nsfile_safe') "; 	 

$nsfilename = "/tmp/$uid-$nsref.nsfile";

if (! ($fp = fopen($nsfilename, "w"))) {
	TBERROR("Could not create temporary file $nsfile", 1);
}

if (strlen( $nsdata ) > 50000) {
	$nsdata = "#(NS file was >50kb big)\n" .
                  "!!! ERROR: NS File Truncated !!!\n";
}

fwrite($fp, $nsdata);
fclose($fp);
?><commit_msg>Fixed stupid NS4.7 issue where totally empty document was causing problems.<commit_after><?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#

chdir("..");
include("defs.php3");

# this is just saving data; it isnt human readable.

#
# Only known and logged in users can begin experiments.
#

if (isset($guid) && ereg("^[0-9]+$", $guid)) {
	$uid = $guid;
} else {
	if (isset($uid)) {
		$uid = GETLOGIN();
		LOGGEDINORDIE($uid);
	} else {
		USERERROR( "Need to send guid or uid!" );
        } 
}

if (!isset($nsdata)) {
	USERERROR( "Need to send NSFILE!" );
} 

if (!isset($nsref) || !ereg("^[0-9]+$", $nsref)) {
	USERERROR( "Need to send valid NSREF!" );
}

#if (isset($nsdata)) {
#    if (strcmp($nsdata, "") == 0) 
#	unset($nsdata);
#   elseif (! isset($submit))
# 	$nsdata = rawurlencode($nsdata);
#}

#$nsfile_safe = addslashes($nsdata);
#$nsref_safe = addslashes($nsref);

#DBQueryFatal("INSERT INTO nsfiles_transient ".
#	     "(nsfileid, time, uid, nsfile) ".
#	     "VALUES ('$nsref_safe', now(), '$uid', '$nsfile_safe') " );

#echo "INSERT INTO nsfiles_transient ".
#     "(nsfileid, time, uid, nsfile) ".
#     "VALUES ('$nsref_safe', now(), '$uid', '$nsfile_safe') "; 	 

$nsfilename = "/tmp/$uid-$nsref.nsfile";

if (! ($fp = fopen($nsfilename, "w"))) {
	TBERROR("Could not create temporary file $nsfile", 1);
}

if (strlen( $nsdata ) > 50000) {
	$nsdata = "#(NS file was >50kb big)\n" .
                  "!!! ERROR: NS File Truncated !!!\n";
}

fwrite($fp, $nsdata);
fclose($fp);

header("Content-Type: text/plain");
echo "success!";
?>
{'fraction_non_alphanumeric': 0.2133676092544987, 'fraction_numerical': 0.014781491002570694, 'mean_word_length': 3.8640625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1968635', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1203, 'n_words': 298}