<commit_before><?php
namespace autoauth;

$config = require('config.php');

$class = new \ReflectionClass($config->hook->class);
if(!$class->isSubclassOf(hooks\IHook::class))
	return http_response_code(500);

$hook = $class->newInstanceArgs($config->hook->args);

$layout = new layout\Page("pages/index.{$hook->userRole()}.xml");

if($_SERVER['REQUEST_METHOD'] === 'POST')
{
	switch($hook->userRole())
	{
	case 'admin':
		$name = $_POST['name'];
		break;

	case 'user':
		$name = $hook->userName();
		break;

	default:
		return;
	}

	$out = $layout->{'//html:input[@readonly]'}->item(0);

	if(!strlen($name))
		$out->setAttribute('value', 'Username cannot be empty!');
	else
	{
		//TODO
		$out->setAttribute('value', "UUID for '$name'");
	}
}

$layout->display();<commit_msg>Handle the guest-POST case better<commit_after><?php
namespace autoauth;

$config = require('config.php');

$class = new \ReflectionClass($config->hook->class);
if(!$class->isSubclassOf(hooks\IHook::class))
	return http_response_code(500);

$hook = $class->newInstanceArgs($config->hook->args);

$layout = new layout\Page("pages/index.{$hook->userRole()}.xml");

if($_SERVER['REQUEST_METHOD'] === 'POST')
{
	switch($hook->userRole())
	{
	case 'admin':
		$name = $_POST['name'];
		break;

	case 'user':
		$name = $hook->userName();
		break;
	}
}

if(isset($name))
{
	$out = $layout->{'//html:input[@readonly]'}->item(0);

	if(!strlen($name))
		$out->setAttribute('value', 'Username cannot be empty!');
	else
	{
		//TODO
		$out->setAttribute('value', "UUID for '$name'");
	}
}

$layout->display();
{'fraction_non_alphanumeric': 0.23439490445859873, 'fraction_numerical': 0.005095541401273885, 'mean_word_length': 5.3603238866396765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1327099', 'n_tokens_mistral': 590, 'n_tokens_neox': 574, 'n_words': 96}