<commit_before><?php
/**
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines http://www.simplemachines.org
 * @copyright 2015 Simple Machines and individual contributors
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.1 Beta 2
 */

// This is just the basic "login" form.
function template_login()
{
	global $context, $settings, $scripturl, $modSettings, $txt;

	echo '
		<div class="tborder login">
			<div class="cat_bar">
				<h3 class="catbg">
					<img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon"> ', $txt['login'], '
				</h3>
			</div>
			<div class="roundframe">
				<form class="login" action="', $context['login_url'], '" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '">';

	// Did they make a mistake last time?
	if (!empty($context['login_errors']))
		echo '
					<div class="errorbox">', implode('<br>', $context['login_errors']), '</div><br>';

	// Or perhaps there's some special description for this time?
	if (isset($context['description']))
		echo '
					<p class="information">', $context['description'], '</p>';

	// Now just get the basic information - username, password, etc.
	echo '
					<dl>
						<dt>', $txt['username'], ':</dt>
						<dd><input type="text" id="', !empty($context['from_ajax']) ? 'ajax_' : '', 'loginuser" name="user" size="20" value="', $context['default_username'], '" class="input_text"></dd>
						<dt>', $txt['password'], ':</dt>
						<dd><input type="password" id="', !empty($context['from_ajax']) ? 'ajax_' : '', 'loginpass" name="passwrd" value="', $context['default_password'], '" size="20" class="input_password"></dd>
					</dl>
					<dl>
						<dt>', $txt['mins_logged_in'], ':</dt>
						<dd><input type="number" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '"', $context['never_expire'] ? ' disabled' : '', ' class="input_text" min="1" max="525600"></dd>
						<dt>', $txt['always_logged_in'], ':</dt>
						<dd><input type="checkbox" name="cookieneverexp"', $context['never_expire'] ? ' checked' : '', ' class="input_check" onclick="this.form.cookielength.disabled = this.checked;"></dd>';
	// If they have deleted their account, give them a chance to change their mind.
	if (isset($context['login_show_undelete']))
		echo '
						<dt class="alert">', $txt['undelete_account'], ':</dt>
						<dd><input type="checkbox" name="undelete" class="input_check"></dd>';
	echo '
					</dl>
					<p><input type="submit" value="', $txt['login'], '" class="button_submit"></p>
					<p class="smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
					<input type="hidden" name="hash_passwrd" value="">
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
					<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
					<script type="text/javascript">
						setTimeout(function() {
							document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus();
						}, 150);';
	if (!empty($context['from_ajax']) && (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] == 2))
		echo '
						form = $("#frmLogin");
						form.submit(function(e) {
							e.preventDefault();
							e.stopPropagation();

							$.ajax({
								url: form.prop("action"),
								method: "POST",
								data: form.serialize(),
								success: function(data) {
									if (data.indexOf("<bo" + "dy") > -1)
										document.location = ', JavaScriptEscape(!empty($_SESSION['login_url']) ? $_SESSION['login_url'] : $scripturl), ';
									else {
										form.parent().html($(data).find(".roundframe").html());
									}
								},
								error: function() {
									document.location = ', JavaScriptEscape(!empty($_SESSION['login_url']) ? $_SESSION['login_url'] : $scripturl), ';
								}
							});

							return false;
						});';

	echo '
					</script>
				</form>';

	// It is a long story as to why we have this when we're clearly not going to use it.
	if (!empty($context['from_ajax']))
		echo '
					<br>
					<a href="javascript:self.close();"></a>';
	echo '
			</div>
		</div>';
}

// TFA authentication
function template_login_tfa()
{
	global $context, $scripturl, $modSettings, $txt;

	echo '
		<div class="tborder login">
			<div class="cat_bar">
				<h3 class="catbg">
					', $txt['tfa_profile_label'] ,'
				</h3>
			</div>
			<div class="roundframe">';
	if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error']))
		echo '
				<div class="error">', $txt['tfa_' . (!empty($context['tfa_error']) ? 'code_' : 'backup_') . 'invalid'], '</div>';
	echo '
				<form action="', $context['tfa_url'], '" method="post" id="frmTfa">
					<div id="tfaCode">
						', $txt['tfa_login_desc'], '<br>
						<div>
							<strong>', $txt['tfa_code'], ':</strong>
							<input type="text" class="input_text" name="tfa_code" style="width: 150px;" value="', !empty($context['tfa_value']) ? $context['tfa_value'] : '', '">
							<input type="submit" class="button_submit" name="submit" value="', $txt['login'], '" style="float: none; margin: 0;"><br />
						</div><br />
						<div><input type="checkbox" value="1" name="tfa_preserve" />&nbsp;', $txt['tfa_preserve'], '</div>
						<hr />
						<input type="button" class="button_submit" name="backup" value="', $txt['tfa_backup'], '" style="float: none; margin: 0;">
					</div>
					<div id="tfaBackup" style="display: none;">
						', $txt['tfa_backup_desc'], '<br><commit_msg>Slight HTML cleanup for 2FA<commit_after><?php
/**
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines http://www.simplemachines.org
 * @copyright 2015 Simple Machines and individual contributors
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.1 Beta 2
 */

// This is just the basic "login" form.
function template_login()
{
	global $context, $settings, $scripturl, $modSettings, $txt;

	echo '
		<div class="tborder login">
			<div class="cat_bar">
				<h3 class="catbg">
					<img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon"> ', $txt['login'], '
				</h3>
			</div>
			<div class="roundframe">
				<form class="login" action="', $context['login_url'], '" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '">';

	// Did they make a mistake last time?
	if (!empty($context['login_errors']))
		echo '
					<div class="errorbox">', implode('<br>', $context['login_errors']), '</div><br>';

	// Or perhaps there's some special description for this time?
	if (isset($context['description']))
		echo '
					<p class="information">', $context['description'], '</p>';

	// Now just get the basic information - username, password, etc.
	echo '
					<dl>
						<dt>', $txt['username'], ':</dt>
						<dd><input type="text" id="', !empty($context['from_ajax']) ? 'ajax_' : '', 'loginuser" name="user" size="20" value="', $context['default_username'], '" class="input_text"></dd>
						<dt>', $txt['password'], ':</dt>
						<dd><input type="password" id="', !empty($context['from_ajax']) ? 'ajax_' : '', 'loginpass" name="passwrd" value="', $context['default_password'], '" size="20" class="input_password"></dd>
					</dl>
					<dl>
						<dt>', $txt['mins_logged_in'], ':</dt>
						<dd><input type="number" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '"', $context['never_expire'] ? ' disabled' : '', ' class="input_text" min="1" max="525600"></dd>
						<dt>', $txt['always_logged_in'], ':</dt>
						<dd><input type="checkbox" name="cookieneverexp"', $context['never_expire'] ? ' checked' : '', ' class="input_check" onclick="this.form.cookielength.disabled = this.checked;"></dd>';
	// If they have deleted their account, give them a chance to change their mind.
	if (isset($context['login_show_undelete']))
		echo '
						<dt class="alert">', $txt['undelete_account'], ':</dt>
						<dd><input type="checkbox" name="undelete" class="input_check"></dd>';
	echo '
					</dl>
					<p><input type="submit" value="', $txt['login'], '" class="button_submit"></p>
					<p class="smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
					<input type="hidden" name="hash_passwrd" value="">
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
					<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
					<script type="text/javascript">
						setTimeout(function() {
							document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus();
						}, 150);';
	if (!empty($context['from_ajax']) && (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] == 2))
		echo '
						form = $("#frmLogin");
						form.submit(function(e) {
							e.preventDefault();
							e.stopPropagation();

							$.ajax({
								url: form.prop("action"),
								method: "POST",
								data: form.serialize(),
								success: function(data) {
									if (data.indexOf("<bo" + "dy") > -1)
										document.location = ', JavaScriptEscape(!empty($_SESSION['login_url']) ? $_SESSION['login_url'] : $scripturl), ';
									else {
										form.parent().html($(data).find(".roundframe").html());
									}
								},
								error: function() {
									document.location = ', JavaScriptEscape(!empty($_SESSION['login_url']) ? $_SESSION['login_url'] : $scripturl), ';
								}
							});

							return false;
						});';

	echo '
					</script>
				</form>';

	// It is a long story as to why we have this when we're clearly not going to use it.
	if (!empty($context['from_ajax']))
		echo '
					<br>
					<a href="javascript:self.close();"></a>';
	echo '
			</div>
		</div>';
}

// TFA authentication
function template_login_tfa()
{
	global $context, $scripturl, $modSettings, $txt;

	echo '
		<div class="tborder login">
			<div class="cat_bar">
				<h3 class="catbg">
					', $txt['tfa_profile_label'] ,'
				</h3>
			</div>
			<div class="roundframe">';
	if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error']))
		echo '
				<div class="error">', $txt['tfa_' . (!empty($context['tfa_error']) ? 'code_' : 'backup_') . 'invalid'], '</div>';
	echo '
				<form action="', $context['tfa_url'], '" method="post" id="frmTfa">
					<div id="tfaCode">
						', $txt['tfa_login_desc'], '<br>
						<div>
							<strong>', $txt['tfa_code'], ':</strong>
							<input type="text" class="input_text" name="tfa_code" style="width: 150px;" value="', !empty($context['tfa_value']) ? $context['tfa_value'] : '', '">
							<input type="submit" class="button_submit" name="submit" value="', $txt['login'], '" style="float: none; margin: 0;"><br />
						</div><br />
						<div><input type="checkbox" value="1" name="tfa_preserve" id="tfa_preserve"/><label for="tfa_preserve">&nbsp;', $txt['tfa_preserve'], '</label></div>
						<hr />
						<input type="button" class="button_submit" name="backup" value="', $txt['tfa_backup'], '" style="float: none; margin: 0;">
					</div>
					<div id="tfaBackup" style="display: none;">
						', $txt['tfa_backup_desc'], '<br>
{'fraction_non_alphanumeric': 0.22907067721463967, 'fraction_numerical': 0.006172302877510215, 'mean_word_length': 4.088014153029633, 'pattern_counts': {'":': 0, '<': 185, '<?xml version=': 0, '>': 183, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '3930902', 'n_tokens_mistral': 4609, 'n_tokens_neox': 3767, 'n_words': 794}