<commit_before><?php
/**
* This file contains generel functions available throughout the site
*
* @package Functions
*/

/**
* Include additional functions
*/
//include_once("functions_arrays.inc.php");
//include_once("functions_files.inc.php");

/**
* used by zip
*/

function utf8Encode($string) {
	$new_string = '';	
	for($i = 0; $i < strlen($string); $i++){ 
		//print "$i: ".$string{$i}.": ".mb_detect_encoding($string{$i});
		if(mb_detect_encoding($string{$i})) {
			$new_string .= $string{$i};
		}
	}
	$encoding = mb_detect_encoding($new_string);
	if($encoding != "UTF-8") {
		//$string = utf8_encode($new_string);
		$string = mb_convert_encoding($new_string, "UTF-8", $encoding);
	}
	return $string;	
}

/**
* Parse REST parameters from url
* returns array if no index is specified
* returns string if index is specified
* returns false if parameters (or specified index) does not exist
* 
* @param int $index Optional parameter index to return
* @return boolean|array|string
*/
function RESTParams($index=false) {
	// no path
	if(!isset($_SERVER["PATH_INFO"]) || $_SERVER["PATH_INFO"] == "/") {
		return false;
	}
	else {
		// get params
		$params = explode("/", substr($_SERVER["PATH_INFO"], 1));
		if($index !== false && isset($params[$index])) {
			return $params[$index];
		}
		else {
			return $params;
		}
	}<commit_msg>RESTParams now returns empty array in stead of false<commit_after><?php
/**
* This file contains generel functions available throughout the site
*
* @package Functions
*/

/**
* Include additional functions
*/
//include_once("functions_arrays.inc.php");
//include_once("functions_files.inc.php");

/**
* used by zip
*/

function utf8Encode($string) {
	$new_string = '';	
	for($i = 0; $i < strlen($string); $i++){ 
		//print "$i: ".$string{$i}.": ".mb_detect_encoding($string{$i});
		if(mb_detect_encoding($string{$i})) {
			$new_string .= $string{$i};
		}
	}
	$encoding = mb_detect_encoding($new_string);
	if($encoding != "UTF-8") {
		//$string = utf8_encode($new_string);
		$string = mb_convert_encoding($new_string, "UTF-8", $encoding);
	}
	return $string;	
}

/**
* Parse REST parameters from url
* returns array if no index is specified
* returns string if index is specified
* returns false if parameters (or specified index) does not exist
* 
* @param int $index Optional parameter index to return
* @return boolean|array|string
*/
function RESTParams($index=false) {
	// no path
	if(!isset($_SERVER["PATH_INFO"]) || $_SERVER["PATH_INFO"] == "/") {
		// TODO:Check if this works everywhere 

		// EXPERIMENTAL: Testing if returning empty array will suffice
//		return false;
		return array();
	}
	else {
		// get params
		$params = explode("/", substr($_SERVER["PATH_INFO"], 1));
		if($index !== false && isset($params[$index])) {
			return $params[$index];
		}
		else {
			return $params;
		}
	}
{'fraction_non_alphanumeric': 0.17729996475149806, 'fraction_numerical': 0.0042298202326401125, 'mean_word_length': 4.354716981132076, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 3, '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': '3804040', 'n_tokens_mistral': 974, 'n_tokens_neox': 918, 'n_words': 239}