<commit_before><?php

// Init owncloud
require_once('../../lib/base.php');

// We send json data
// header( "Content-Type: application/json" );
// Firefox and Konqueror tries to download application/json for me.  --Arthur
header( "Content-Type: text/plain" );

// Check if we are a user
if( !OC_USER::isLoggedIn()){
	echo json_encode( array( "status" => "error", "data" => "Authentication error" ));
	exit();
}

$fileName=$_FILES['file']['name'];
$source=$_FILES['file']['tmp_name'];
$dir = $_POST['dir'];
if(!empty($dir)) $dir .= '/';
$target='/' . stripslashes($dir) . $fileName;
if(isset($_SESSION['username'])
and $_SESSION['username'] and strpos($dir,'..') === false){
	if(OC_FILESYSTEM::fromUploadedFile($source,$target)){
// 	if(OC_FILES::move(dirname($source),basename($source), $dir, $fileName)){
		echo json_encode(array( "status" => "success"));
		exit();
	}
}

$error = $_FILES['file']['error'];

echo json_encode(array( 'status' => 'error', 'data' => array('error' => $error)));

?><commit_msg>removed deprecated session check, which blocked file upload in some cases<commit_after><?php

// Init owncloud
require_once('../../lib/base.php');

// We send json data
// header( "Content-Type: application/json" );
// Firefox and Konqueror tries to download application/json for me.  --Arthur
header( "Content-Type: text/plain" );

// Check if we are a user
if( !OC_USER::isLoggedIn()){
	echo json_encode( array( "status" => "error", "data" => "Authentication error" ));
	exit();
}

$fileName=$_FILES['file']['name'];
$source=$_FILES['file']['tmp_name'];
$dir = $_POST['dir'];
if(!empty($dir)) $dir .= '/';
$target='/' . stripslashes($dir) . $fileName;
if(strpos($dir,'..') === false){
	if(OC_FILESYSTEM::fromUploadedFile($source,$target)){
		echo json_encode(array( "status" => "success"));
		exit();
	}
}

$error = $_FILES['file']['error'];

echo json_encode(array( 'status' => 'error', 'data' => array('error' => $error)));

?>
{'fraction_non_alphanumeric': 0.23581011351909184, 'fraction_numerical': 0.0, 'mean_word_length': 5.420529801324503, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '5071376', 'n_tokens_mistral': 663, 'n_tokens_neox': 654, 'n_words': 151}