<commit_before><?php

$page_access = 'anonymous';

require_once __DIR__ . '/include/web.php';

$token = $_GET['token'] ?? false;

if (!$app['config']->get('contact_form_en', $app['tschema']))
{
	$app['alert']->warning('De contactpagina is niet ingeschakeld.');
	redirect_login();
}

if ($token)
{
	$key = $app['tschema'] . '_contact_' . $token;
	$data = $app['predis']->get($key);

	if ($data)
	{
		$app['predis']->del($key);

		$data = json_decode($data, true);

		$vars = [
			'message'		=> $data['message'],
			'ip'			=> $data['ip'],
			'agent'			=> $data['agent'],
			'email'			=> $data['email'],
		];

		$app['queue.mail']->queue([
			'schema'	=> $app['tschema'],
			'template'	=> 'contact/copy',
			'vars'		=> $vars,
			'to'		=> [$data['email']],
		], 9000);

		$app['queue.mail']->queue([
			'schema'	=> $app['tschema'],
			'template'	=> 'contact/support',
			'vars'		=> $vars,
			'to'		=> $app['mail_addr_system']->get_support($app['tschema']),
			'reply_to'	=> [$data['email']],
		], 8000);

		$app['alert']->success('Je bericht werd succesvol verzonden.');

		$success_text = $app['config']->get('contact_form_success_text', $app['tschema']);

		header('Location: ' . generate_url('contact', []));
		exit;
	}

	$app['alert']->error('Ongeldig of verlopen token.');
}

if($app['is_http_post'] && isset($_POST['zend']))
{
	$email = trim(strtolower($_POST['email']));
	$message = trim($_POST['message']);

	$agent = $_SERVER['HTTP_USER_AGENT'];

	if (isset($_SERVER['HTTP_CLIENT_IP']))
	{
		$ip = $_SERVER['HTTP_CLIENT_IP'];
	}
	else if (isset($_SERVER['HTTP_X_FORWARDE‌​D_FOR']))
	{
		$ip = $_SERVER['HTTP_X_FORWARDE‌​D_FOR'];
	}
	else
	{
		$ip = $_SERVER['REMOTE_ADDR'];
	}

	if (empty($email) || !$email)
	{
		$errors[] = 'Vul je E-mail adres in';
	}

	if (!filter_var($email, FILTER_VALIDATE_EMAIL))
	{
		$errors[] = 'Geen geldig E-mail adres';
	}

	if (empty($message) || strip_tags($message) == '' || !$message)
	{
		$errors[] = 'Geef een bericht in.';
	}

	if (!trim($app['config']->get('support', $app['tschema'])))
	{
		$errors[] = 'Het Support E-mail adres is niet ingesteld in dit Systeem';
	}

	if ($token_error = $app['form_token']->get_error())
	{
		$errors[] = $token_error;
	}

	if(!count($errors))
	{
		$contact = [
			'message' 	=> $message,
			'email'		=> $email,
			'agent'		=> $agent,
			'ip'		=> $ip,
		];

		$token = substr(hash('sha512', $app['tschema'] . microtime()), 0, 10);
		$key = $app['tschema'] . '_contact_' . $token;
		$app['predis']->set($key, json_encode($contact));
		$app['predis']->expire($key, 86400);

		$app['monolog']->info('Contact form filled in with address ' .
			$email . ' ' .
			json_encode($contact),
			['schema' => $app['tschema']]);

		$vars = [
			'token'			=> $token,
		];

		$app['queue.mail']->queue([
			'schema'	=> $app['tschema'],
			'to' 		=> [$email],<commit_msg>contact ref #162<commit_after><?php

$page_access = 'anonymous';

require_once __DIR__ . '/include/web.php';

$token = $_GET['token'] ?? false;

if (!$app['config']->get('contact_form_en', $app['tschema']))
{
	$app['alert']->warning('De contactpagina is niet ingeschakeld.');
	redirect_login();
}

if ($token)
{
	$key = $app['tschema'] . '_contact_' . $token;
	$data = $app['predis']->get($key);

	if ($data)
	{
		$app['predis']->del($key);

		$data = json_decode($data, true);

		$vars = [
			'message'		=> $data['message'],
			'ip'			=> $data['ip'],
			'agent'			=> $data['agent'],
			'email'			=> $data['email'],
		];

		$app['queue.mail']->queue([
			'schema'	=> $app['tschema'],
			'template'	=> 'contact/copy',
			'vars'		=> $vars,
			'to'		=> [$data['email'] => $data['email']],
		], 9000);

		$app['queue.mail']->queue([
			'schema'	=> $app['tschema'],
			'template'	=> 'contact/support',
			'vars'		=> $vars,
			'to'		=> $app['mail_addr_system']->get_support($app['tschema']),
			'reply_to'	=> [$data['email']],
		], 8000);

		$app['alert']->success('Je bericht werd succesvol verzonden.');

		$success_text = $app['config']->get('contact_form_success_text', $app['tschema']);

		header('Location: ' . generate_url('contact', []));
		exit;
	}

	$app['alert']->error('Ongeldig of verlopen token.');
}

if($app['is_http_post'] && isset($_POST['zend']))
{
	$email = trim(strtolower($_POST['email']));
	$message = trim($_POST['message']);

	$agent = $_SERVER['HTTP_USER_AGENT'];

	if (isset($_SERVER['HTTP_CLIENT_IP']))
	{
		$ip = $_SERVER['HTTP_CLIENT_IP'];
	}
	else if (isset($_SERVER['HTTP_X_FORWARDE‌​D_FOR']))
	{
		$ip = $_SERVER['HTTP_X_FORWARDE‌​D_FOR'];
	}
	else
	{
		$ip = $_SERVER['REMOTE_ADDR'];
	}

	if (empty($email) || !$email)
	{
		$errors[] = 'Vul je E-mail adres in';
	}

	if (!filter_var($email, FILTER_VALIDATE_EMAIL))
	{
		$errors[] = 'Geen geldig E-mail adres';
	}

	if (empty($message) || strip_tags($message) == '' || !$message)
	{
		$errors[] = 'Geef een bericht in.';
	}

	if (!trim($app['config']->get('support', $app['tschema'])))
	{
		$errors[] = 'Het Support E-mail adres is niet ingesteld in dit Systeem';
	}

	if ($token_error = $app['form_token']->get_error())
	{
		$errors[] = $token_error;
	}

	if(!count($errors))
	{
		$contact = [
			'message' 	=> $message,
			'email'		=> $email,
			'agent'		=> $agent,
			'ip'		=> $ip,
		];

		$token = substr(hash('sha512', $app['tschema'] . microtime()), 0, 10);
		$key = $app['tschema'] . '_contact_' . $token;
		$app['predis']->set($key, json_encode($contact));
		$app['predis']->expire($key, 86400);

		$app['monolog']->info('Contact form filled in with address ' .
			$email . ' ' .
			json_encode($contact),
			['schema' => $app['tschema']]);

		$vars = [
			'token'			=> $token,
		];

		$app['queue.mail']->queue([
			'schema'	=> $app['tschema'],
			'to' 		=> [$email => $email],
{'fraction_non_alphanumeric': 0.25759438103599647, 'fraction_numerical': 0.007199297629499561, 'mean_word_length': 4.2887650882079855, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 79, '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': '3973824', 'n_tokens_mistral': 2527, 'n_tokens_neox': 2318, 'n_words': 373}