<commit_before><div id="content">
<?php
	if (isset($MSG)){
		echo "<h1>$MSG</h1>";
		if (isset($SubMSG)) echo "<p>$SubMSG</p>";
	}
	else {
		echo get_avatar_wrap($User); ?>
	<h1><?=$User['name']?> <a class="da" title="Visit DeviantArt profile" href="<?=da_link($User,LINK_ONLY)?>"><svg xmlns="http://www.w3.org/2000/svg" version="1" viewBox="0 0 100 167"><path d=" M100 0 L99.96 0 L99.95 0 L71.32 0 L68.26 3.04 L53.67 30.89 L49.41 33.35 L0 33.35 L0 74.97 L26.40 74.97 L29.15 77.72 L0 133.36 L0 166.5 L0 166.61 L0 166.61 L28.70 166.6 L31.77 163.55 L46.39 135.69 L50.56 133.28 L100 133.28 L100 91.68 L73.52 91.68 L70.84 89 L100 33.33 "></path><image src="//st.deviantart.net/minish/main/logo/logo-mark.png"></image></svg></a></h1>
	<p><?php
		echo "<span>{$User['rolelabel']}</span>";
		if ($canEdit){
			echo ' <button id="change-role" class="blue typcn typcn-spanner'.($User['role']==='ban'?' hidden':'').'" title="Change '.s($User['name']).' group"></button>';
			$BanLabel = ($User['role']==='ban'?'Un-ban':'Ban').'ish';
			$Icon = $User['role']==='ban'?'world':'weather-night';
			if (PERM('inspector', $User['role']))
				$Icon .= ' hidden';
			echo ' <button id="ban-toggle" class="darkblue typcn typcn-'.$Icon.' '.strtolower($BanLabel).'" title="'."$BanLabel user".'"></button>';
		}
	?></p>
	<div class="details">
<?  if (PERM('developer')){ ?>
		<section>
			<label>User ID:</label>
			<span><?=$User['id']?></span>
		</section>
<?  }

	$PrivateSection = "<span class='typcn typcn-lock-closed' title='Only visible to you and group administrators'></span>";

	$cols = 'id, CONCAT("S", season, "E", episode) as page, season, preview, label, posted';
	$PendingReservations = $Database->where('reserved_by', $User['id'])->where('deviation_id IS NULL')->get('reservations',null,$cols);
	$PendingRequestReservations = $Database->where('reserved_by', $User['id'])->where('deviation_id IS NULL')->get('requests',null,$cols.', 1 as rq');
	$TotalPending = count($PendingReservations)+count($PendingRequestReservations);
	$hasPending = $TotalPending > 0;
	if ((PERM('inspector') || $sameUser) && PERM('member', $User['role'])){ ?>
		<section class="pending-reservations">
			<label><?=$PrivateSection?>Pending Reservations</label>
			<span><?=($sameUser?'You have':'This user has').' '.($hasPending>0?"<strong>$TotalPending</strong>":'no')?> pending reservation<?php
		echo $TotalPending!==1?'s':'';
		if ($hasPending)
			echo " which ha".($TotalPending!==1?'ve':'s')."n't been marked as finished yet";
		echo ".";
		if ($sameUser)
			echo " Please keep in mind that the global limit is 4 at any given time. If you reach the limit, you can't reserve any more images until you finish or cancel some of your current reservations.";
			?></span>
<?php
		if ($hasPending){
			$Posts = array_merge(
				reservations_render($PendingReservations, RETURN_ARRANGED)['unfinished'],
				array_filter(array_values(requests_render($PendingRequestReservations, RETURN_ARRANGED)['unfinished']))
			);
			usort($Posts, function($a, $b){
				$a = strtotime($a['posted']);
				$b = strtotime($b['posted']);

				return -($a < $b ? -1 : ($a === $b ? 0 : 1));
			});
			foreach ($Posts as $i => $p){
				$thing = isset($p['rq']) ? 'request' : 'reservation';
				$id = "$thing-{$p['id']}";
				if ($p['season'] !== 0){
					$link = "/episode/{$p['page']}#$id";
					$page = $p['page'];
				}
				else {
					$movieNumber = preg_replace('/^.*E(\d+)$/','$1',$p['page']);
					$link = "/eqg/$movieNumber";
					$page = "EQG #$movieNumber";
				}
				$posted = date('c',strtotime($p['posted']));
				$Posts[$i] = <<<HTML
<li id='$id'>
	<div class='image screencap'>
		<a href='$link'><img src='{$p['preview']}'></a>
	</div>
	<span class='label'>{$p['label']}</span>
	<em>Posted under <a href='$link'>$page</a> <time datetime="$posted"></em>
	<div>
		<a href='$link' class='btn blue typcn typcn-arrow-forward'>View</a>
	</div>
</li>

HTML;
			}
			echo "<ul>".implode('',$Posts)."</ul>";
		}
?>
		</section>
<?      $AwaitingApproval = $Database->rawQuery(
			"SELECT IFNULL(req.deviation_id,res.deviation_id) as deviation
			FROM requests req
			LEFT JOIN reservations res ON req.reserved_by = res.reserved_by
			WHERE
				(req.reserved_by = ? && req.deviation_id IS NOT NULL && req.`lock` = 0)
				|| (res.reserved_by = ? && res.deviation_id IS NOT NULL && res.`lock` = 0)",array($User['id'],$User['id'])); ?>
		<section class="awaiting-approval">
			<label><?=$PrivateSection?>Vectors pending approval</label>
			<p>After you finish an image and submit it to the group gallery, an inspector will check your vector and may ask you to fix some issues on your image, if any. When an image is accepted to the gallery, it will be marked as "approved" on this site, which gives it a green check mark, indicating that it's most likely free of any errors.</p>
			<p>You currently have <?=empty($AwaitingApproval)?'no':'<strong>'.count($AwaitingApproval).'</strong>'?> images waiting for approval by our group<?=empty($AwaitingApproval)?'.':", listed below. We suggest that you submit these images to the group gallery at your earliest convenience to have them spot-checked for any issues and to have them added to the gallery to make it easier to find for others."?></p>
<?php   if (!empty($AwaitingApproval)){ ?>
			<ul><?
			foreach ($AwaitingApproval as $row){
				$deviation = da_cache_deviation($row['deviation']);
				$url = "http://{$deviation['provider']}/{$deviation['id']}";
				echo <<<HTML
<li>
	<div class="image deviation">
		<a href="$url" target="_blank">
			<img src="{$deviation['preview']}" alt="{$deviation['title']}">
		</a>
	</div>
	<span class="label"><a href="$url" target="_blank">{$deviation['title']}</span>
</li>
HTML;

			} ?></ul>
<?php   } ?><commit_msg>Forgot to close <a> tag<commit_after><div id="content">
<?php
	if (isset($MSG)){
		echo "<h1>$MSG</h1>";
		if (isset($SubMSG)) echo "<p>$SubMSG</p>";
	}
	else {
		echo get_avatar_wrap($User); ?>
	<h1><?=$User['name']?> <a class="da" title="Visit DeviantArt profile" href="<?=da_link($User,LINK_ONLY)?>"><svg xmlns="http://www.w3.org/2000/svg" version="1" viewBox="0 0 100 167"><path d=" M100 0 L99.96 0 L99.95 0 L71.32 0 L68.26 3.04 L53.67 30.89 L49.41 33.35 L0 33.35 L0 74.97 L26.40 74.97 L29.15 77.72 L0 133.36 L0 166.5 L0 166.61 L0 166.61 L28.70 166.6 L31.77 163.55 L46.39 135.69 L50.56 133.28 L100 133.28 L100 91.68 L73.52 91.68 L70.84 89 L100 33.33 "></path><image src="//st.deviantart.net/minish/main/logo/logo-mark.png"></image></svg></a></h1>
	<p><?php
		echo "<span>{$User['rolelabel']}</span>";
		if ($canEdit){
			echo ' <button id="change-role" class="blue typcn typcn-spanner'.($User['role']==='ban'?' hidden':'').'" title="Change '.s($User['name']).' group"></button>';
			$BanLabel = ($User['role']==='ban'?'Un-ban':'Ban').'ish';
			$Icon = $User['role']==='ban'?'world':'weather-night';
			if (PERM('inspector', $User['role']))
				$Icon .= ' hidden';
			echo ' <button id="ban-toggle" class="darkblue typcn typcn-'.$Icon.' '.strtolower($BanLabel).'" title="'."$BanLabel user".'"></button>';
		}
	?></p>
	<div class="details">
<?  if (PERM('developer')){ ?>
		<section>
			<label>User ID:</label>
			<span><?=$User['id']?></span>
		</section>
<?  }

	$PrivateSection = "<span class='typcn typcn-lock-closed' title='Only visible to you and group administrators'></span>";

	$cols = 'id, CONCAT("S", season, "E", episode) as page, season, preview, label, posted';
	$PendingReservations = $Database->where('reserved_by', $User['id'])->where('deviation_id IS NULL')->get('reservations',null,$cols);
	$PendingRequestReservations = $Database->where('reserved_by', $User['id'])->where('deviation_id IS NULL')->get('requests',null,$cols.', 1 as rq');
	$TotalPending = count($PendingReservations)+count($PendingRequestReservations);
	$hasPending = $TotalPending > 0;
	if ((PERM('inspector') || $sameUser) && PERM('member', $User['role'])){ ?>
		<section class="pending-reservations">
			<label><?=$PrivateSection?>Pending Reservations</label>
			<span><?=($sameUser?'You have':'This user has').' '.($hasPending>0?"<strong>$TotalPending</strong>":'no')?> pending reservation<?php
		echo $TotalPending!==1?'s':'';
		if ($hasPending)
			echo " which ha".($TotalPending!==1?'ve':'s')."n't been marked as finished yet";
		echo ".";
		if ($sameUser)
			echo " Please keep in mind that the global limit is 4 at any given time. If you reach the limit, you can't reserve any more images until you finish or cancel some of your current reservations.";
			?></span>
<?php
		if ($hasPending){
			$Posts = array_merge(
				reservations_render($PendingReservations, RETURN_ARRANGED)['unfinished'],
				array_filter(array_values(requests_render($PendingRequestReservations, RETURN_ARRANGED)['unfinished']))
			);
			usort($Posts, function($a, $b){
				$a = strtotime($a['posted']);
				$b = strtotime($b['posted']);

				return -($a < $b ? -1 : ($a === $b ? 0 : 1));
			});
			foreach ($Posts as $i => $p){
				$thing = isset($p['rq']) ? 'request' : 'reservation';
				$id = "$thing-{$p['id']}";
				if ($p['season'] !== 0){
					$link = "/episode/{$p['page']}#$id";
					$page = $p['page'];
				}
				else {
					$movieNumber = preg_replace('/^.*E(\d+)$/','$1',$p['page']);
					$link = "/eqg/$movieNumber";
					$page = "EQG #$movieNumber";
				}
				$posted = date('c',strtotime($p['posted']));
				$Posts[$i] = <<<HTML
<li id='$id'>
	<div class='image screencap'>
		<a href='$link'><img src='{$p['preview']}'></a>
	</div>
	<span class='label'>{$p['label']}</span>
	<em>Posted under <a href='$link'>$page</a> <time datetime="$posted"></em>
	<div>
		<a href='$link' class='btn blue typcn typcn-arrow-forward'>View</a>
	</div>
</li>

HTML;
			}
			echo "<ul>".implode('',$Posts)."</ul>";
		}
?>
		</section>
<?      $AwaitingApproval = $Database->rawQuery(
			"SELECT IFNULL(req.deviation_id,res.deviation_id) as deviation
			FROM requests req
			LEFT JOIN reservations res ON req.reserved_by = res.reserved_by
			WHERE
				(req.reserved_by = ? && req.deviation_id IS NOT NULL && req.`lock` = 0)
				|| (res.reserved_by = ? && res.deviation_id IS NOT NULL && res.`lock` = 0)",array($User['id'],$User['id'])); ?>
		<section class="awaiting-approval">
			<label><?=$PrivateSection?>Vectors pending approval</label>
			<p>After you finish an image and submit it to the group gallery, an inspector will check your vector and may ask you to fix some issues on your image, if any. When an image is accepted to the gallery, it will be marked as "approved" on this site, which gives it a green check mark, indicating that it's most likely free of any errors.</p>
			<p>You currently have <?=empty($AwaitingApproval)?'no':'<strong>'.count($AwaitingApproval).'</strong>'?> images waiting for approval by our group<?=empty($AwaitingApproval)?'.':", listed below. We suggest that you submit these images to the group gallery at your earliest convenience to have them spot-checked for any issues and to have them added to the gallery to make it easier to find for others."?></p>
<?php   if (!empty($AwaitingApproval)){ ?>
			<ul><?
			foreach ($AwaitingApproval as $row){
				$deviation = da_cache_deviation($row['deviation']);
				$url = "http://{$deviation['provider']}/{$deviation['id']}";
				echo <<<HTML
<li>
	<div class="image deviation">
		<a href="$url" target="_blank">
			<img src="{$deviation['preview']}" alt="{$deviation['title']}">
		</a>
	</div>
	<span class="label"><a href="$url" target="_blank">{$deviation['title']}</a></span>
</li>
HTML;

			} ?></ul>
<?php   } ?>
{'fraction_non_alphanumeric': 0.2216915595692949, 'fraction_numerical': 0.03351858284126433, 'mean_word_length': 4.701485148514852, 'pattern_counts': {'":': 2, '<': 217, '<?xml version=': 0, '>': 223, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '68445', 'n_tokens_mistral': 4687, 'n_tokens_neox': 4053, 'n_words': 1002}