<commit_before><?php
if ( ! defined('e107_INIT')) {
	require_once __DIR__ . '/../../class2.php';
}
if ( ! e107::isInstalled('mentions')) {
	exit;
}

if (e_AJAX_REQUEST && strtolower($_SERVER['REQUEST_METHOD']) === 'get' && vartrue($_GET['mq'])) {

	$db = e107::getDb();
	$tp = e107::getParser();

	$mq =
		$tp->filter($_GET['mq']); // TODO --> ? should it be mysql escaping - but what about server resource overhead??
	$where = "user_name LIKE '" . $mq . "%' ";

	if ($db->select('user', 'user_name, user_login',
		$where . ' ORDER BY user_name')
	) {

		$data = [];
		while ($row = $db->fetch()) {
			$data[] = [
				'username' => $row['user_name'],
				'name'     => $row['user_login'],
			];
		}

		if (count($data)) {
			//TODO -  ?? $data need filter_var_array as its going to be parsed as html on frontend, ?? xss csrf
			$ajax = e107::getAjax();
			$ajax->response($data);
		}
	}

}
exit;<commit_msg>Separate HTTP method check block.<commit_after><?php
if ( ! defined('e107_INIT')) {
	require_once __DIR__ . '/../../class2.php';
}
if ( ! e107::isInstalled('mentions')) {
	exit;
}

if (strtolower($_SERVER['REQUEST_METHOD']) === 'post') {
	exit;
}

$mq = null;

if (e_AJAX_REQUEST && vartrue($_GET['mq'])) {

	$db = e107::getDb();
	$tp = e107::getParser();

	$mq =
		$tp->filter($_GET['mq']); // TODO --> ? should it be mysql escaping - but will it cause server overhead??
	$where = "user_name LIKE '" . $mq . "%' ";

	if ($db->select('user', 'user_name, user_login',
		$where . ' ORDER BY user_name')
	) {

		$data = [];
		while ($row = $db->fetch()) {
			$data[] = [
				'username' => $row['user_name'],
				'name'     => $row['user_login'],
			];
		}

		if (count($data)) {
			//TODO -  ?? $data need filter_var_array as its going to be parsed as html on frontend, ?? xss csrf
			$ajax = e107::getAjax();
			$ajax->response($data);
		}
	}

}
{'fraction_non_alphanumeric': 0.2281081081081081, 'fraction_numerical': 0.017297297297297298, 'mean_word_length': 3.3862559241706163, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '2907670', 'n_tokens_mistral': 775, 'n_tokens_neox': 694, 'n_words': 156}