<commit_before><?php
	require_once('../lib/env.php');

	require_once('http.php');
	require_once('session.php');
	require_once('db.php');

	switch ($_SERVER['REQUEST_METHOD']) {
		case 'GET':
			if (isset($_SESSION['user'])) {
				$customer = $db_driver->getCustomer($_SESSION['user']['customer']);
				if ($customer === null)
					httpResponse(204, null);
				if ($customer)
					httpResponse(200, $customer);
				httpResponse(500, null);
			} else
				httpResponse(401, array('message' => 'Not logged in'));
			break;

		case 'POST':
			if (isset($_SESSION['user'])) {
				$fields = httpParseInput();
				$fields['id'] = $_SESSION['user']['customer'];
				$res = $db_driver->updateCustomer($fields);
				if ($res === true)
					httpResponse(200, array('message' => 'ok !'));
				if ($res)
					httpResponse(400, array('message' => $res));
				httpResponse(500, null);
			} else
				httpResponse(401, array('message' => 'Not logged in'));
			break;

		case 'OPTIONS':
			httpOptionsMethod(HTTP_ALL_METHODS & ~HTTP_PUT & ~HTTP_DELETE);
			break;

		default:
			httpUnsupportedMethod();
			break;
	}
?><commit_msg>Add checkConnectedt()<commit_after><?php
	require_once('../lib/env.php');

	require_once('http.php');
	require_once('session.php');
	require_once('db.php');

	switch ($_SERVER['REQUEST_METHOD']) {
		case 'GET':
			checkConnected();

			$customer = $db_driver->getCustomer($_SESSION['user']['customer']);
			if ($customer === null)
				httpResponse(204, null);
			if ($customer)
				httpResponse(200, $customer);
			httpResponse(500, null);

			break;

		case 'POST':
			checkConnected();

			$fields = httpParseInput();
			$fields['id'] = $_SESSION['user']['customer'];
			$res = $db_driver->updateCustomer($fields);
			if ($res === true)
				httpResponse(200, array('message' => 'Successfully updated'));
			if ($res)
				httpResponse(400, array('message' => $res));
			httpResponse(500, null);

			break;

		case 'OPTIONS':
			httpOptionsMethod(HTTP_ALL_METHODS & ~HTTP_PUT & ~HTTP_DELETE);
			break;

		default:
			httpUnsupportedMethod();
			break;
	}
?>
{'fraction_non_alphanumeric': 0.193719806763285, 'fraction_numerical': 0.020289855072463767, 'mean_word_length': 4.31025641025641, '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': '2454639', 'n_tokens_mistral': 837, 'n_tokens_neox': 670, 'n_words': 128}