<commit_before><?php

require("globals.php");

if (isset($_GET['id']))
{
	if (isset($_GET['deny']))
	{
		$db->query("DELETE `russian_roulette` WHERE `challenger` = '{$_GET['id']}' AND `challengee' = '{$userid}'");
		echo "{$lang['RUSSIANROULETTE_DENIED']}";
		require ("footer.php");
		die();
	}
	$q = $db->query("SELECT `challenger` FROM `russian_roulette` WHERE `challenger` = '{$_GET['id']}' AND `challengee' = '{$userid}'");
	if ($db->num_rows($q) == 0)
	{
		$q = $db->query("SELECT * FROM `users` WHERE `userid` = '{$_GET['id']}'");
		if ($db->num_rows($q) != 0)
		{
			$r = $db->fetch_row($q);
			echo "{$lang['RUSSIANROULETTE_NO_INVITE']}";
			require ("footer.php");
			die();
		}
		echo "{$lang['RUSSIANROULETTE_INVALID_ACCOUNT']}";
		require ("footer.php");
		die();
	}
	else
	{
		$q = $db->query("SELECT * FROM `russian_roulette` WHERE `challenger` = '{$_GET['id']}' AND `challengee' = '{$userid}'");
		$r2 = $db->fetch_row($q);
		if ($ir['primary_currency'] < $r2['reward'])
		{
			echo "{$lang['RUSSIANROULETTE_INSUFFICIENT_CURRENCY']}";
			require ("footer.php");
			die();
		}
		$q = $db->query("SELECT * FROM `users` WHERE `userid` = '{$_GET['id']}'");
		$r = $db->fetch_row($q);
		if ($r['primary_currency'] < $r2['reward'])
		{
			echo "{$lang['RUSSIANROULETTE_SCAM']}";
			require ("footer.php");
			die();
		}
		$rand = mt_rand(1, 8);
		$player = mt_rand(1, 2);
		$shot = false;
		if ($player == 1)
		{
			if ($rand == 1)
			{
				$shot = true;
			}
			if ($rand == 3)
			{
				$shot = true;
			}
			if ($rand == 5)
			{
				$shot = true;
			}
			if ($rand == 7)
			{
				$shot = true;
			}
			echo "{$lang['RUSSIANROULETTE_FIRST']}";
		}
		else if ($player == 2)
		{
			if ($rand == 2)
			{
				$shot = true;
			}
			if ($rand == 4)
			{
				$shot = true;
			}
			if ($rand == 6)
			{
				$shot = true;
			}
			if ($rand == 8)
			{
				$shot = true;
			}
			echo "{$lang['RUSSIANROULETTE_SECOND']}";
		}
		if ($rand == 1)
		{
			$result = "1st";
		}
		if ($rand == 2)
		{
			$result = "2nd";
		}
		if ($rand == 3)
		{
			$result = "3rd";
		}
		if ($rand == 4)
		{
			$result = "4th";
		}
		if ($rand == 5)
		{
			$result = "5th";
		}
		if ($rand == 6)
		{
			$result = "6th";
		}
		if ($rand == 7)
		{
			$result = "7th";
		}
		if ($rand == 8)
		{
			$result = "8th";
		}
		if ($shot == false)
		{
			$q = $db->query("SELECT * FROM `russian_roulette` WHERE `challenger` = '{$_GET['id']}' AND `challengee' = '{$userid}'");
			$r = $db->fetch_row($q);
			$q = $db->query("SELECT * FROM `users` WHERE `userid` = '{$_GET['id']}'");
			$r2 = $db->fetch_row($q);
			echo "<br><br>{$lang['RUSSIANROULETTE_WON']}";
			$db->query("UPDATE `users` SET `primary_currency` = `primary_currency` - '{$r['reward']}' WHERE `userid` = '{$_GET['id']}");
			$db->query("UPDATE `users` SET `primary_currency` = `primary_currency` + '{$r['reward']}' WHERE `userid` = '{$userid}");
			$hosptime = Random(75, 175) + floor($r2['level'] / 2);
			$hospreason = $db->escape("Played the wrong game with <a href='profile.php?user={$userid}'>{$ir['username']}</a>");
			$db->query("UPDATE `users` SET `hp` = 1 WHERE `userid` = {$_GET['id']}");
			put_infirmary($_GET['id'],$hosptime,$hospreason);
		}
		if ($shot == true)
		{
			$q = $db->query("SELECT * FROM `russian_roulette` WHERE `challenger` = '{$_GET['id']}' AND `challengee' = '{$userid}'");
			$r = $db->fetch_row($q);
			$q = $db->query("SELECT * FROM `users` WHERE `userid` = '{$_GET['id']}'");
			$r2 = $db->fetch_row($q);
		echo "<br><br>{$lang['RUSSIANROULETTE_LOST']}";
			$db->query("UPDATE `users` SET `primary_currency` = `primary_currency` + '{$r['reward']}' WHERE `userid` = '{$_GET['id']}");
			$db->query("UPDATE `users` SET `primary_currency` = `primary_currency` - '{$r['reward']}' WHERE `userid` = '{$userid}");
			$hosptime = Random(75, 175) + floor($ir['level'] / 2);
			$hospreason = $db->escape("Played the wrong game with <a href='profile.php?user={$_GET['id']}'>{$r2['username']}</a>");
			$db->query("UPDATE `users` SET `hp` = 1 WHERE `userid` = {$_GET['id']}");
			put_infirmary($userid,$hosptime,$hospreason);
		}
	}
}
else
{
	if (!isset($_POST['user_id']))
	{
		echo "
		<form method='post' class='form' role='form'>
			<table class='table table-bordered'><commit_msg>And again omg izzy<commit_after><?php

require("globals.php");

if (isset($_GET['id']))
{
	if (isset($_GET['deny']))
	{
		$db->query("DELETE `russian_roulette` WHERE `challenger` = '{$_GET['id']}' AND `challengee` = '{$userid}'");
		echo "{$lang['RUSSIANROULETTE_DENIED']}";
		require ("footer.php");
		die();
	}
	$q = $db->query("SELECT `challenger` FROM `russian_roulette` WHERE `challenger` = '{$_GET['id']}' AND `challengee` = '{$userid}'");
	if ($db->num_rows($q) == 0)
	{
		$q = $db->query("SELECT * FROM `users` WHERE `userid` = '{$_GET['id']}'");
		if ($db->num_rows($q) != 0)
		{
			$r = $db->fetch_row($q);
			echo "{$lang['RUSSIANROULETTE_NO_INVITE']}";
			require ("footer.php");
			die();
		}
		echo "{$lang['RUSSIANROULETTE_INVALID_ACCOUNT']}";
		require ("footer.php");
		die();
	}
	else
	{
		$q = $db->query("SELECT * FROM `russian_roulette` WHERE `challenger` = '{$_GET['id']}' AND `challengee` = '{$userid}'");
		$r2 = $db->fetch_row($q);
		if ($ir['primary_currency'] < $r2['reward'])
		{
			echo "{$lang['RUSSIANROULETTE_INSUFFICIENT_CURRENCY']}";
			require ("footer.php");
			die();
		}
		$q = $db->query("SELECT * FROM `users` WHERE `userid` = '{$_GET['id']}'");
		$r = $db->fetch_row($q);
		if ($r['primary_currency'] < $r2['reward'])
		{
			echo "{$lang['RUSSIANROULETTE_SCAM']}";
			require ("footer.php");
			die();
		}
		$rand = mt_rand(1, 8);
		$player = mt_rand(1, 2);
		$shot = false;
		if ($player == 1)
		{
			if ($rand == 1)
			{
				$shot = true;
			}
			if ($rand == 3)
			{
				$shot = true;
			}
			if ($rand == 5)
			{
				$shot = true;
			}
			if ($rand == 7)
			{
				$shot = true;
			}
			echo "{$lang['RUSSIANROULETTE_FIRST']}";
		}
		else if ($player == 2)
		{
			if ($rand == 2)
			{
				$shot = true;
			}
			if ($rand == 4)
			{
				$shot = true;
			}
			if ($rand == 6)
			{
				$shot = true;
			}
			if ($rand == 8)
			{
				$shot = true;
			}
			echo "{$lang['RUSSIANROULETTE_SECOND']}";
		}
		if ($rand == 1)
		{
			$result = "1st";
		}
		if ($rand == 2)
		{
			$result = "2nd";
		}
		if ($rand == 3)
		{
			$result = "3rd";
		}
		if ($rand == 4)
		{
			$result = "4th";
		}
		if ($rand == 5)
		{
			$result = "5th";
		}
		if ($rand == 6)
		{
			$result = "6th";
		}
		if ($rand == 7)
		{
			$result = "7th";
		}
		if ($rand == 8)
		{
			$result = "8th";
		}
		if ($shot == false)
		{
			$q = $db->query("SELECT * FROM `russian_roulette` WHERE `challenger` = '{$_GET['id']}' AND `challengee` = '{$userid}'");
			$r = $db->fetch_row($q);
			$q = $db->query("SELECT * FROM `users` WHERE `userid` = '{$_GET['id']}'");
			$r2 = $db->fetch_row($q);
			echo "<br><br>{$lang['RUSSIANROULETTE_WON']}";
			$db->query("UPDATE `users` SET `primary_currency` = `primary_currency` - '{$r['reward']}' WHERE `userid` = '{$_GET['id']}'");
			$db->query("UPDATE `users` SET `primary_currency` = `primary_currency` + '{$r['reward']}' WHERE `userid` = '{$userid}'");
			$hosptime = Random(75, 175) + floor($r2['level'] / 2);
			$hospreason = $db->escape("Played the wrong game with <a href='profile.php?user={$userid}'>{$ir['username']}</a>");
			$db->query("UPDATE `users` SET `hp` = 1 WHERE `userid` = {$_GET['id']}");
			put_infirmary($_GET['id'],$hosptime,$hospreason);
		}
		if ($shot == true)
		{
			$q = $db->query("SELECT * FROM `russian_roulette` WHERE `challenger` = '{$_GET['id']}' AND `challengee` = '{$userid}'");
			$r = $db->fetch_row($q);
			$q = $db->query("SELECT * FROM `users` WHERE `userid` = '{$_GET['id']}'");
			$r2 = $db->fetch_row($q);
		echo "<br><br>{$lang['RUSSIANROULETTE_LOST']}";
			$db->query("UPDATE `users` SET `primary_currency` = `primary_currency` + '{$r['reward']}' WHERE `userid` = '{$_GET['id']}'");
			$db->query("UPDATE `users` SET `primary_currency` = `primary_currency` - '{$r['reward']}' WHERE `userid` = '{$userid}'");
			$hosptime = Random(75, 175) + floor($ir['level'] / 2);
			$hospreason = $db->escape("Played the wrong game with <a href='profile.php?user={$_GET['id']}'>{$r2['username']}</a>");
			$db->query("UPDATE `users` SET `hp` = 1 WHERE `userid` = {$_GET['id']}");
			put_infirmary($userid,$hosptime,$hospreason);
		}
	}
}
else
{
	if (!isset($_POST['user_id']))
	{
		echo "
		<form method='post' class='form' role='form'>
			<table class='table table-bordered'>
{'fraction_non_alphanumeric': 0.2606238964096527, 'fraction_numerical': 0.012477928193054738, 'mean_word_length': 3.6835722160970232, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 75, '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': '4793463', 'n_tokens_mistral': 4108, 'n_tokens_neox': 3589, 'n_words': 672}