<commit_before><?php

require_once('../../incl/incl.php');
require_once('../../incl/memcache.incl.php');
require_once('../../incl/api.incl.php');

$fields = array('from', 'subject', 'message');
foreach ($fields as $field) {
    if (!isset($_POST[$field])) {
        json_return(false);
    }
}

if ($_POST['subject'] != "Subject") {
    json_return(false);
}

unset($_POST['subject']);

$headers = array();
$headers['Date'] = Date(DATE_RFC2822);
$headers['Content-Type'] = 'text/plain; charset=ISO-8859-1; format=flowed';
$headers['From'] = 'Contact Form <<EMAIL>>';

if (preg_match('/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['from'], $res) > 0) {
    $headers['Reply-To'] = $res[0];
}

$_POST['message'] = preg_replace('/\r\n?/', "\n", $_POST['message']);

$body = "Date: " . Date('Y-m-d H:i:s') . "\nFrom: " . $_POST['from'] . "\nIP: " . $_SERVER['REMOTE_ADDR'] . "\nUser Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\n";

$banned = BotCheck(true);
$body .= "Banned: " . ($banned['isbanned'] ? 'yes: ' . $banned['reason'] . ' ' . $banned['ip'] : 'no') . "\n";

if (isset($_POST['region'])) {
    $body .= "Region: " . $_POST['region'] . "\n";
}
if (isset($_POST['realm'])) {
    $body .= "Realm: " . $_POST['realm'] . "\n";
}
if (isset($_POST['house'])) {
    $body .= "House: " . $_POST['house'] . "\n";
}

$body .= "\n---------------\n" . $_POST['message'];

$body = preg_replace_callback('/(?<=^|\n)([^\n]+)(?:\n|$)/', create_function('$m', 'return ((strlen(trim($m[1]))>0)?wordwrap($m[1],66," \n"):"")."\n";'), strip_8bit_chars(utf8_decode(strip_tags(str_replace('&amp;', '&', str_replace('&quot;', '"', str_replace('&lt;', '<', $body)))))));
<commit_msg>include username in contact form emails<commit_after><?php

require_once '../../incl/incl.php';
require_once '../../incl/memcache.incl.php';
require_once '../../incl/api.incl.php';
require_once '../../incl/subscription.incl.php';

$fields = array('from', 'subject', 'message');
foreach ($fields as $field) {
    if (!isset($_POST[$field])) {
        json_return(false);
    }
}

if ($_POST['subject'] != "Subject") {
    json_return(false);
}

unset($_POST['subject']);

$headers = array();
$headers['Date'] = Date(DATE_RFC2822);
$headers['Content-Type'] = 'text/plain; charset=ISO-8859-1; format=flowed';
$headers['From'] = 'Contact Form <<EMAIL>>';

if (preg_match('/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['from'], $res) > 0) {
    $headers['Reply-To'] = $res[0];
}

$_POST['message'] = preg_replace('/\r\n?/', "\n", $_POST['message']);

$body = "Date: " . Date('Y-m-d H:i:s') . "\nFrom: " . $_POST['from'] . "\nIP: " . $_SERVER['REMOTE_ADDR'] . "\nUser Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\n";

$banned = BotCheck(true);
$body .= "Banned: " . ($banned['isbanned'] ? 'yes: ' . $banned['reason'] . ' ' . $banned['ip'] : 'no') . "\n";

$loginState = GetLoginState();
$body .= "User: ".(isset($loginState['id']) ? ($loginState['id'] . ' ' . $loginState['name']) : 'none') . "\n";

if (isset($_POST['region'])) {
    $body .= "Region: " . $_POST['region'] . "\n";
}
if (isset($_POST['realm'])) {
    $body .= "Realm: " . $_POST['realm'] . "\n";
}
if (isset($_POST['house'])) {
    $body .= "House: " . $_POST['house'] . "\n";
}

$body .= "\n---------------\n" . $_POST['message'];

$body = preg_replace_callback('/(?<=^|\n)([^\n]+)(?:\n|$)/', create_function('$m', 'return ((strlen(trim($m[1]))>0)?wordwrap($m[1],66," \n"):"")."\n";'), strip_8bit_chars(utf8_decode(strip_tags(str_replace('&amp;', '&', str_replace('&quot;', '"', str_replace('&lt;', '<', $body)))))));

{'fraction_non_alphanumeric': 0.3254637436762226, 'fraction_numerical': 0.013490725126475547, 'mean_word_length': 4.165457184325109, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '3182070', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1419, 'n_words': 211}