<commit_before><?php
require $_SERVER['DOCUMENT_ROOT'] . '/php/header.php';

if ($signed_in)
{
?>

		<a id='dashboard'></a>
		<div class='container row text-center'>
			<h1>Dashboard<br><small>Your account is <span class='account-<?php echo strtolower($account_level) ?>'><?php echo $account_level ?> <i class='fa fa-trophy'></i></span></small></h1>
			<p><a class='btn btn-default btn-sm' href='/account'>Update account</a></p>
			<hr>
		</div>

		<a id='resources'></a>
		<div class='container row text-center'>
			<h1>Resources <i class='fa fa-compass'></i></h1>
			<p>Check out our most recent articles, workouts, and recipes below. Be sure to visit often so you don't miss anything!</p>
		</div>
		<div class='container row text-center'>
			<div class='col-sm-6 col-md-4'>
				<h3><i class='fa fa-newspaper-o fa-5x'></i></h3>
				<h2>Recent articles</h2>

<?php
	$stmt = $db->prepare('SELECT id, level, title, date FROM articles WHERE level=\'' . implode('\' or level=\'', $account_levels_inherited) . '\' ORDER BY id DESC LIMIT 5');
	$stmt->execute();
	$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

	if ($results)
	{	foreach ($results as $article)
		{	$days_ago_string = get_days_ago_string($article['date']);
?>

				<br>
				<h4><a href='article?id=<?php echo $article['id'] ?>'><?php echo $article['title'] ?></a></h4>
				<p>Published <?php echo $days_ago_string ?></p>

<?php
		}
?>

				<br>
				<p><a class='btn btn-default' href='articles'>View all</a></p>

<?php
	}
	else
	{
?>

				<br>
				<p><?php echo $ERROR_MESSAGE['no_articles'] ?></p>

<?php
	}
?>

			</div>

			<div class='col-sm-6 col-md-4'>
				<h3><i class='fa fa-child fa-5x'></i></h3>
				<h2>Recent workouts</h2>

<?php
	$stmt = $db->prepare('SELECT id, level, title, date FROM workouts WHERE level=\'' . implode('\' or level=\'', $account_levels_inherited) . '\' ORDER BY id DESC LIMIT 5');
	$stmt->execute();
	$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

	if ($results)
	{	foreach ($results as $workout)
		{	$days_ago_string = get_days_ago_string($workout['date']);
?>

				<br>
				<h4><a href='workout?id=<?php echo $workout['id'] ?>'><?php echo $workout['title'] ?></a></h4>
				<p>Published <?php echo $days_ago_string ?></p>

<?php
		}
?>

				<br>
				<p><a class='btn btn-default' href='workouts'>View all</a></p>

<?php
	}
	else
	{
?>

				<br>
				<p><?php echo $ERROR_MESSAGE['no_workouts'] ?></p>

<?php
	}
?>

			</div>

			<div class='col-sm-6 col-md-4'>
				<h3><i class='fa fa-cutlery fa-5x'></i></h3>
				<h2>Recent recipes</h2>

<?php
	$stmt = $db->prepare('SELECT id, level, title, date FROM recipes WHERE level=\'' . implode('\' or level=\'', $account_levels_inherited) . '\' ORDER BY id DESC LIMIT 5');
	$stmt->execute();
	$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

	if ($results)
	{	foreach ($results as $recipe)
		{	$days_ago_string = get_days_ago_string($recipe['date']);
?>

				<br>
				<h4><a href='recipe?id=<?php echo $recipe['id'] ?>'><?php echo $recipe['title'] ?></a></h4>
				<p>Published <?php echo $days_ago_string ?></p>

<?php
		}
?><commit_msg>Limit home page to 3 articles<commit_after><?php
require $_SERVER['DOCUMENT_ROOT'] . '/php/header.php';

if ($signed_in)
{
?>

		<a id='dashboard'></a>
		<div class='container row text-center'>
			<h1>Dashboard<br><small>Your account is <span class='account-<?php echo strtolower($account_level) ?>'><?php echo $account_level ?> <i class='fa fa-trophy'></i></span></small></h1>
			<p><a class='btn btn-default btn-sm' href='/account'>Update account</a></p>
			<hr>
		</div>

		<a id='resources'></a>
		<div class='container row text-center'>
			<h1>Resources <i class='fa fa-compass'></i></h1>
			<p>Check out our most recent articles, workouts, and recipes below. Be sure to visit often so you don't miss anything!</p>
		</div>
		<div class='container row text-center'>
			<div class='col-sm-6 col-md-4'>
				<h3><i class='fa fa-newspaper-o fa-5x'></i></h3>
				<h2>Recent articles</h2>

<?php
	$stmt = $db->prepare('SELECT id, level, title, date FROM articles WHERE level=\'' . implode('\' or level=\'', $account_levels_inherited) . '\' ORDER BY id DESC LIMIT 3');
	$stmt->execute();
	$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

	if ($results)
	{	foreach ($results as $article)
		{	$days_ago_string = get_days_ago_string($article['date']);
?>

				<br>
				<h4><a href='article?id=<?php echo $article['id'] ?>'><?php echo $article['title'] ?></a></h4>
				<p>Published <?php echo $days_ago_string ?></p>

<?php
		}
?>

				<br>
				<p><a class='btn btn-default' href='articles'>View all</a></p>

<?php
	}
	else
	{
?>

				<br>
				<p><?php echo $ERROR_MESSAGE['no_articles'] ?></p>

<?php
	}
?>

			</div>

			<div class='col-sm-6 col-md-4'>
				<h3><i class='fa fa-child fa-5x'></i></h3>
				<h2>Recent workouts</h2>

<?php
	$stmt = $db->prepare('SELECT id, level, title, date FROM recipes WHERE level=\'' . implode('\' or level=\'', $account_levels_inherited) . '\' ORDER BY id DESC LIMIT 3');
	$stmt->execute();
	$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

	if ($results)
	{	foreach ($results as $workout)
		{	$days_ago_string = get_days_ago_string($workout['date']);
?>

				<br>
				<h4><a href='workout?id=<?php echo $workout['id'] ?>'><?php echo $workout['title'] ?></a></h4>
				<p>Published <?php echo $days_ago_string ?></p>

<?php
		}
?>

				<br>
				<p><a class='btn btn-default' href='workouts'>View all</a></p>

<?php
	}
	else
	{
?>

				<br>
				<p><?php echo $ERROR_MESSAGE['no_workouts'] ?></p>

<?php
	}
?>

			</div>

			<div class='col-sm-6 col-md-4'>
				<h3><i class='fa fa-cutlery fa-5x'></i></h3>
				<h2>Recent recipes</h2>

<?php
	$stmt = $db->prepare('SELECT id, level, title, date FROM workouts WHERE level=\'' . implode('\' or level=\'', $account_levels_inherited) . '\' ORDER BY id DESC LIMIT 3');
	$stmt->execute();
	$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

	if ($results)
	{	foreach ($results as $recipe)
		{	$days_ago_string = get_days_ago_string($recipe['date']);
?>

				<br>
				<h4><a href='recipe?id=<?php echo $recipe['id'] ?>'><?php echo $recipe['title'] ?></a></h4>
				<p>Published <?php echo $days_ago_string ?></p>

<?php
		}
?>
{'fraction_non_alphanumeric': 0.22799610263072426, 'fraction_numerical': 0.01120493666774927, 'mean_word_length': 4.015472312703583, 'pattern_counts': {'":': 0, '<': 229, '<?xml version=': 0, '>': 247, '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': '2031412', 'n_tokens_mistral': 2663, 'n_tokens_neox': 2419, 'n_words': 537}