<commit_before><?php
/*
 *  BanManagement © 2015, a web interface for the Bukkit plugin BanManager
 *  by <NAME> of http://www.frostcast.net
 *  is licenced under a Creative Commons
 *  Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales.
 *  Permissions beyond the scope of this licence
 *  may be available at http://creativecommons.org/licenses/by-nc-sa/2.0/uk/.
 *  Additional licence terms at https://raw.githubusercontent.com/BanManagement/BanManager-WebUI/master/LICENSE
 */

if(empty($settings['password']) || $settings['password'] == 'password')
	errors('You have not set a password. For your security, it\'s required that you set one.');
else if(isset($_SESSION['failed_attempts']) && $_SESSION['failed_attempts'] > 4) {
	die(errors('You have reached the maximum number of attempts. Please try again in 30 minutes.'));
	if($_SESSION['failed_attempt'] < time())
		unset($_SESSION['failed_attempts']);
} else if(!isset($_SESSION['admin']) && !isset($_POST['password'])) {
	?><form action="" method="post" class="well form-inline">
	<h3>Admin Control Panel <small>&mdash; If you forgot your password please refer to settings.php to change it.</small></h3>
	<div class="row">
		<div class="col-lg-6">
		<?php
			if(!empty($errors)){
				foreach ($errors as $error) {
					echo $error;
				}
			}
		?>
			<div class="input-group">
			<input type="password" class="form-control" name="password" placeholder="Password">
				<span class="input-group-btn">
				<button class="btn btn-info" type="submit">Sign In</button>
					</span>
				</div>
			</div>
		</div>
		</form><?php
} else if(isset($_POST['password']) && !isset($_SESSION['admin'])) {
	if(htmlspecialchars_decode($_POST['password'], ENT_QUOTES) != $settings['password']) {
		//set how long we want them to have to wait after 5 wrong attempts
		$time = 1800; //make them wait 30 mins
		if(isset($_SESSION['failed_attempts']))
			++$_SESSION['failed_attempts'];
		else
			$_SESSION['failed_attempts'] = 1;
		$_SESSION['failed_attempt'] = time() + $time;
		redirect('index.php?action=admin');
	} else {
		$_SESSION['admin'] = true;
		redirect('index.php?action=admin');
	}
} else if(isset($_SESSION['admin']) && $_SESSION['admin']) {
	?>
	<table class="table table-striped table-bordered" id="servers">
		<thead>
			<tr>
				<th>Server Name</th>
				<th>Options</th>
			</tr>
		</thead>
		<tbody><?php
	if(empty($settings['servers']))
		echo '<tr id="noservers"><td colspan="2">No Servers Defined</td></tr>';
	else {
		$id = array_keys($settings['servers']);
		$i = 0;
		$count = count($settings['servers']) - 1;

		foreach($settings['servers'] as $server) {
			echo '
				<tr>
					<td>'.$server['name'].'</td>
					<td>
						<a href="#" class="btn btn-danger deleteServer" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-trash"></span></a>';<commit_msg>Return error on failed admin authentication<commit_after><?php
/*
 *  BanManagement © 2015, a web interface for the Bukkit plugin BanManager
 *  by <NAME> of http://www.frostcast.net
 *  is licenced under a Creative Commons
 *  Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales.
 *  Permissions beyond the scope of this licence
 *  may be available at http://creativecommons.org/licenses/by-nc-sa/2.0/uk/.
 *  Additional licence terms at https://raw.githubusercontent.com/BanManagement/BanManager-WebUI/master/LICENSE
 */

if(empty($settings['password']) || $settings['password'] == 'password')
	errors('You have not set a password. For your security, it\'s required that you set one.');
else if(isset($_SESSION['failed_attempts']) && $_SESSION['failed_attempts'] > 4) {
	die(errors('You have reached the maximum number of attempts. Please try again in 30 minutes.'));
	if($_SESSION['failed_attempt'] < time())
		unset($_SESSION['failed_attempts']);
} else if(!isset($_SESSION['admin']) && !isset($_POST['password'])) {
	?><form action="" method="post" class="well form-inline">
	<h3>Admin Control Panel <small>&mdash; If you forgot your password please refer to settings.php to change it.</small></h3>
	<div class="row">
		<div class="col-lg-6">
		<?php
			if(!empty($errors)){
				foreach ($errors as $error) {
					echo $error;
				}
			}
		?>
			<div class="input-group">
			<input type="password" class="form-control" name="password" placeholder="Password">
				<span class="input-group-btn">
				<button class="btn btn-info" type="submit">Sign In</button>
					</span>
				</div>
			</div>
		</div>
		</form><?php
} else if(isset($_POST['password']) && !isset($_SESSION['admin'])) {
	if(htmlspecialchars_decode($_POST['password'], ENT_QUOTES) != $settings['password']) {
		//set how long we want them to have to wait after 5 wrong attempts
		$time = 1800; //make them wait 30 mins
		if(isset($_SESSION['failed_attempts']))
			++$_SESSION['failed_attempts'];
		else
			$_SESSION['failed_attempts'] = 1;
		$_SESSION['failed_attempt'] = time() + $time;
		errors('Wrong password. Please <a href="index.php?action=admin">try again</a>.');
	} else {
		$_SESSION['admin'] = true;
		redirect('index.php?action=admin');
	}
} else if(isset($_SESSION['admin']) && $_SESSION['admin']) {
	?>
	<table class="table table-striped table-bordered" id="servers">
		<thead>
			<tr>
				<th>Server Name</th>
				<th>Options</th>
			</tr>
		</thead>
		<tbody><?php
	if(empty($settings['servers']))
		echo '<tr id="noservers"><td colspan="2">No Servers Defined</td></tr>';
	else {
		$id = array_keys($settings['servers']);
		$i = 0;
		$count = count($settings['servers']) - 1;

		foreach($settings['servers'] as $server) {
			echo '
				<tr>
					<td>'.$server['name'].'</td>
					<td>
						<a href="#" class="btn btn-danger deleteServer" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-trash"></span></a>';
{'fraction_non_alphanumeric': 0.19151894334376085, 'fraction_numerical': 0.008689607229753215, 'mean_word_length': 4.555019305019305, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 93, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '3989775', 'n_tokens_mistral': 2089, 'n_tokens_neox': 1859, 'n_words': 457}