<commit_before><?php
require_once __DIR__."/../api.php";
require_once __DIR__."/../db.php";
require_once __DIR__."/../core/theme.php";
require_once __DIR__."/../core/legacy_user.php";

$response = json_NewResponse();

// MAIN (Only accept POST requests) //
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
	$action = trim($_POST['action']);
	
	$user = legacy_GetUserFromCookie();
	$node = 100;//intval($CONFIG['event-active']);//isset($_POST['node']) ? intval($_POST['node']) : 0;

	if ( ($user > 0) && ($node > 0) ) {
		$ideas_left = 10 - theme_CountMyIdeas($node,$user);
		
		if ( $action == "GET" ) {
			$response['ideas'] = theme_GetMyIdeas($node,$user);
			$response['ideas_left'] = $ideas_left;
		}
		else if ( $action == "ADD" ) {
			if ( $ideas_left > 0 ) {
				$idea = trim(strip_tags($_POST['idea']));		// TODO: sanitize
		
				if ( !empty($idea) ) {
					$ret = theme_AddMyIdea($idea,$node,$user);
					
					$response['id'] = $ret;
					$response['idea'] = $idea;
					$response['ideas_left'] = $ideas_left - (($ret>0)?1:0);
				}
			}
			else {
				$response['id'] = 0;
				$response['ideas_left'] = $ideas_left;
			}
		}
		else if ( $action == "REMOVE" ) {
			$id = intval($_POST['id']);
			if ( $id > 0 ) {
				// TODO: Is idea id valid?
				
				theme_RemoveMyIdea($id,$user);
				
				$response['id'] = $id;
				$response['ideas_left'] = $ideas_left + (($id>0)?1:0);
			}
		}
//		else {
//			mail("<EMAIL>","loggy2",print_r($_POST,true));
//		}
	}
}

json_Emit($response);
<commit_msg>committing a change that may fix the submission of non-printable spaces<commit_after><?php
require_once __DIR__."/../api.php";
require_once __DIR__."/../db.php";
require_once __DIR__."/../core/theme.php";
require_once __DIR__."/../core/legacy_user.php";

$response = json_NewResponse();

// MAIN (Only accept POST requests) //
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
	$action = trim($_POST['action']);
	
	$user = legacy_GetUserFromCookie();
	$node = 100;//intval($CONFIG['event-active']);//isset($_POST['node']) ? intval($_POST['node']) : 0;

	if ( ($user > 0) && ($node > 0) ) {
		$ideas_left = 10 - theme_CountMyIdeas($node,$user);
		
		if ( $action == "GET" ) {
			$response['ideas'] = theme_GetMyIdeas($node,$user);
			$response['ideas_left'] = $ideas_left;
		}
		else if ( $action == "ADD" ) {
			if ( $ideas_left > 0 ) {
				$idea = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u','',strip_tags($_POST['idea']));
		
				if ( !empty($idea) ) {
					$ret = theme_AddMyIdea($idea,$node,$user);
					
					$response['id'] = $ret;
					$response['idea'] = $idea;
					$response['ideas_left'] = $ideas_left - (($ret>0)?1:0);
				}
			}
			else {
				$response['id'] = 0;
				$response['ideas_left'] = $ideas_left;
			}
		}
		else if ( $action == "REMOVE" ) {
			$id = intval($_POST['id']);
			if ( $id > 0 ) {
				// TODO: Is idea id valid?
				
				theme_RemoveMyIdea($id,$user);
				
				$response['id'] = $id;
				$response['ideas_left'] = $ideas_left + (($id>0)?1:0);
			}
		}
//		else {
//			mail("<EMAIL>","loggy2",print_r($_POST,true));
//		}
	}
}

json_Emit($response);

{'fraction_non_alphanumeric': 0.2376079309242085, 'fraction_numerical': 0.011512631915574032, 'mean_word_length': 3.4180790960451977, 'pattern_counts': {'":': 0, '<': 7, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2330216', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1211, 'n_words': 194}