<commit_before><?php
header('Content-Type: application/json; charset=utf-8');

function detectRequestBody() {
    $rawInput = fopen('php://input', 'r');
    $tempStream = fopen('php://temp', 'r+');
    stream_copy_to_stream($rawInput, $tempStream);
    rewind($tempStream);

    return $tempStream;
}


$par = 'ExternalId';

if(!isset($_POST[$par])){
 	$entityBody = stream_get_contents(detectRequestBody());
	$data = json_decode($entityBody);
	$data = $data->{$par};
}else{
	$data = $_POST[$par];
}




$dirImg = trim(\Uoowd\Param::userStore($data),'/');

$imgAr = array();

function trovaImg($root, &$img, $dir=null, $deep = null){
	if(is_null($deep)) $deep =0;
	if(is_null($dir)) $dir = $root;
	$deep++;
	$iter = new \DirectoryIterator($dir);
	foreach($iter as $file){
		if($file->isDir()){
			if(!$file->isDot()) trovaImg($root, $img , $file->getPathname(), $deep);
		}else{

			if($file->getExtension() === 'json') continue;

			$f = str_replace($root, '', $file->getPathname());
			$f = trim($f, DIRECTORY_SEPARATOR);
			$fe = explode( DIRECTORY_SEPARATOR , $f);

			// var_dump($fe[0]);
			// var_dump($f);

			$i = $fe[0];
			if($i === 'avatar') $img['avatar'] = $f;
			if($i === 'profile') $img['profile'][] = $f;
			if($i === 'offers') $img['offers'][] = $f;
		}
		
	}
}

trovaImg($dirImg, $imgAr);

echo json_encode($imgAr);<commit_msg>Aggiustato un baco che non consentiva il funzionamento dello script per l'ottenimento delle immagini nei sistemi UNIX.<commit_after><?php
header('Content-Type: application/json; charset=utf-8');

function detectRequestBody() {
    $rawInput = fopen('php://input', 'r');
    $tempStream = fopen('php://temp', 'r+');
    stream_copy_to_stream($rawInput, $tempStream);
    rewind($tempStream);

    return $tempStream;
}


$par = 'ExternalId';

if(!isset($_POST[$par])){
 	$entityBody = stream_get_contents(detectRequestBody());
	$data = json_decode($entityBody);
	$data = $data->{$par};
}else{
	$data = $_POST[$par];
}




$dirImg = "/".trim(\Uoowd\Param::userStore($data),'/');

$imgAr = array();

function trovaImg($root, &$img, $dir=null, $deep = null){
	if(is_null($deep)) $deep =0;
	if(is_null($dir)) $dir = $root;
	$deep++;
	$iter = new \DirectoryIterator($dir);
	foreach($iter as $file){
		if($file->isDir()){
			if(!$file->isDot()) trovaImg($root, $img , $file->getPathname(), $deep);
		}else{

			if($file->getExtension() === 'json') continue;

			$f = str_replace($root, '', $file->getPathname());
			$f = trim($f, DIRECTORY_SEPARATOR);
			$fe = explode( DIRECTORY_SEPARATOR , $f);

			// var_dump($fe[0]);
			// var_dump($f);

			$i = $fe[0];
			if($i === 'avatar') $img['avatar'][] = $f;
			if($i === 'profile') $img['profile'][] = $f;
			if($i === 'offers') $img['offers'][] = $f;
		}
		
	}
}

trovaImg($dirImg, $imgAr);

echo json_encode($imgAr);
{'fraction_non_alphanumeric': 0.23957219251336898, 'fraction_numerical': 0.00285204991087344, 'mean_word_length': 4.703252032520325, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '6949745', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1074, 'n_words': 199}