<commit_before><?php

$rootpath = './';
$role = 'anonymous';
$allow_anonymous_post = true;
$allow_session = true;

require_once $rootpath . 'includes/inc_default.php';

if(isset($_POST['zend']))
{
	$help = array(
		'letscode' 			=> $_POST['letscode'],
		'mail'				=> $_POST['mail'],
		'subject' 			=> $_POST['subject'],
		'description' 		=> $_POST['description'],
		'browser'			=> $_SERVER['HTTP_USER_AGENT'],
	);

    $errors = array();

	if (!$s_group_self)
	{
		if(empty($help['letscode']))
		{
			$errors[] = 'Vul je letscode in';
		}

		if(empty($help['mail']))
		{
			$errors[] = 'Vul een E-mail adres in';
		}

		if(!($db->fetchColumn('select c.value
			from contact c, type_contact tc
			where c.id_type_contact = tc.id
				and tc.abbrev = \'mail\'
				and c.value = ?', array($help['mail']))))
		{
			$errors[] = 'Dit mailadres is niet gekend in deze installatie';
		}

		if (!($help['user_id'] = $db->fetchColumn('select c.id_user
			from contact c, type_contact tc, users u
			where c.id_type_contact = tc.id
				and tc.abbrev = \'mail\'
				and c.value = ?
				and c.id_user = u.id
				and u.letscode = ?', array($help['mail'], $help['letscode']))))
		{
			$errors[] = 'Gebruiker niet gevonden.';
		}
	}
	else
	{
		$help['user_id'] = $s_id;
	}

	if(empty($help['subject']))
	{
        $errors[] = 'Geef een onderwerp op.';
	}

	if(empty($help['description']))
	{
		$errors[] = 'Geef een omschrijving van je probleem.';
	}

	$to = trim(readconfigfromdb('support'));

	if (empty($to))
	{
		$errors[] = 'Het support email adres is niet ingesteld op deze installatie';
	}

	if ($token_error = get_error_form_token())
	{
		$errors[] = $form_token;
	}

	if(!count($errors))
	{
		$text  = "-- via de website werd het volgende probleem gemeld --\r\n";
		$text .= 'E-mail: ' . $help['mail'] . "\r\n";

		$text .= 'Gebruiker: ' . link_user($help['user_id'], false, false, true) . "\r\n";

		$text .= 'Gebruiker ingelogd: ';
		$text .= ($s_id) ? 'Ja' : 'Nee (Opmerking: het is niet geheel zeker dat dit is de gebruiker zelf is. ';
		$text .= ($s_id) ? '' : 'Iemand anders die het email adres en de letscode kent, kan dit bericht verzonden hebben).';
		$text .= "\r\n\r\n";
		$text .= "------------------------------ Bericht -----------------------------\r\n\r\n";
		$text .= $help['description'] . "\r\n\r\n";
		$text .= "--------------------------------------------------------------------\r\n\r\n";
		$text .= "User Agent:\r\n";
		$text .= $help['browser'] . "\r\n";
		$text .= "\r\n";
		$text .= 'eLAND webserver: ' . gethostname() . "\r\n";

		$return_message =  mail_q(array('to' => $to, 'subject' => $help['subject'], 'text' => $text, 'reply_to' => $user['id']));

		if (!$return_message)
		{
			$alert->success('De support mail is verzonden.');
			header('Location: ' . generate_url(($s_anonymous) ? 'login' : 'index'));
			exit;
		}

		$alert->error('Mail niet verstuurd. ' . $return_message);
	}
	else
	{
		$alert->error($errors);
	}
}
else
{
	$help = array(
		'letscode' 			=> '',
		'mail'				=> '',
		'subject' 			=> '',
		'description' 		=> '',
	);

	if($s_id && $s_group_self)
	{
		$mail = getmailadr($s_id);
<commit_msg>repair reply to in help form<commit_after><?php

$rootpath = './';
$role = 'anonymous';
$allow_anonymous_post = true;
$allow_session = true;

require_once $rootpath . 'includes/inc_default.php';

if(isset($_POST['zend']))
{
	$help = array(
		'letscode' 			=> $_POST['letscode'],
		'mail'				=> $_POST['mail'],
		'subject' 			=> $_POST['subject'],
		'description' 		=> $_POST['description'],
		'browser'			=> $_SERVER['HTTP_USER_AGENT'],
	);

    $errors = array();

	if (!$s_group_self)
	{
		if(empty($help['letscode']))
		{
			$errors[] = 'Vul je letscode in';
		}

		if(empty($help['mail']))
		{
			$errors[] = 'Vul een E-mail adres in';
		}

		if(!($db->fetchColumn('select c.value
			from contact c, type_contact tc
			where c.id_type_contact = tc.id
				and tc.abbrev = \'mail\'
				and c.value = ?', array($help['mail']))))
		{
			$errors[] = 'Dit mailadres is niet gekend in deze installatie';
		}

		if (!($help['user_id'] = $db->fetchColumn('select c.id_user
			from contact c, type_contact tc, users u
			where c.id_type_contact = tc.id
				and tc.abbrev = \'mail\'
				and c.value = ?
				and c.id_user = u.id
				and u.letscode = ?', array($help['mail'], $help['letscode']))))
		{
			$errors[] = 'Gebruiker niet gevonden.';
		}
	}
	else
	{
		$help['user_id'] = $s_id;
	}

	if(empty($help['subject']))
	{
        $errors[] = 'Geef een onderwerp op.';
	}

	if(empty($help['description']))
	{
		$errors[] = 'Geef een omschrijving van je probleem.';
	}

	$to = trim(readconfigfromdb('support'));

	if (empty($to))
	{
		$errors[] = 'Het support email adres is niet ingesteld op deze installatie';
	}

	if ($token_error = get_error_form_token())
	{
		$errors[] = $form_token;
	}

	if(!count($errors))
	{
		$text  = "-- via de website werd het volgende probleem gemeld --\r\n";
		$text .= 'E-mail: ' . $help['mail'] . "\r\n";

		$text .= 'Gebruiker: ' . link_user($help['user_id'], false, false, true) . "\r\n";

		$text .= 'Gebruiker ingelogd: ';
		$text .= ($s_id) ? 'Ja' : 'Nee (Opmerking: het is niet geheel zeker dat dit is de gebruiker zelf is. ';
		$text .= ($s_id) ? '' : 'Iemand anders die het email adres en de letscode kent, kan dit bericht verzonden hebben).';
		$text .= "\r\n\r\n";
		$text .= "------------------------------ Bericht -----------------------------\r\n\r\n";
		$text .= $help['description'] . "\r\n\r\n";
		$text .= "--------------------------------------------------------------------\r\n\r\n";
		$text .= "User Agent:\r\n";
		$text .= $help['browser'] . "\r\n";
		$text .= "\r\n";
		$text .= 'eLAND webserver: ' . gethostname() . "\r\n";

		$return_message =  mail_q(array('to' => $to, 'subject' => $help['subject'], 'text' => $text, 'reply_to' => $help['user_id']));

		if (!$return_message)
		{
			$alert->success('De support mail is verzonden.');
			header('Location: ' . generate_url(($s_anonymous) ? 'login' : 'index'));
			exit;
		}

		$alert->error('Mail niet verstuurd. ' . $return_message);
	}
	else
	{
		$alert->error($errors);
	}
}
else
{
	$help = array(
		'letscode' 			=> '',
		'mail'				=> '',
		'subject' 			=> '',
		'description' 		=> '',
	);

	if($s_id && $s_group_self)
	{
		$mail = getmailadr($s_id);

{'fraction_non_alphanumeric': 0.2521462639109698, 'fraction_numerical': 0.0, 'mean_word_length': 2.753579952267303, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '5570820', 'n_tokens_mistral': 2659, 'n_tokens_neox': 2472, 'n_words': 511}