<commit_before><?php
//  AcmlmBoard XD - Thread submission/preview page
//  Access: users

$title = __("New thread");

AssertForbidden("makeThread");

if(!$loguserid) //Not logged in?
	Kill(__("You must be logged in to post."));

if(isset($_POST['id']))
	$_GET['id'] = $_POST['id'];

if(!isset($_GET['id']))
	Kill(__("Forum ID unspecified."));

$fid = (int)$_GET['id'];

if($loguser['powerlevel'] < 0)
	Kill(__("You're banned."));

$rFora = Query("select * from {forums} where id={0}", $fid);
if(NumRows($rFora))
	$forum = Fetch($rFora);
else
	Kill(__("Unknown forum ID."));

if($forum['locked'])
	Kill(__("This forum is locked."));

if($forum['minpowerthread'] > $loguser['powerlevel'])
	Kill(__("You are not allowed to post threads in this forum."));

if(!isset($_POST['poll']) || isset($_GET['poll']))
	$_POST['poll'] = $_GET['poll'];


$OnlineUsersFid = $fid;

MakeCrumbs(array($forum['title']=>actionLink("forum", $fid), __("New thread")=>""), $links);

if(isset($_POST['actionpreview']))
{
	if($_POST['poll'])
	{
		$options = array();
		$noColors = 0;
		$defaultColors = array(
			"#000000","#0000B6","#00B600","#00B6B6","#B60000","#B600B6","#B66700","#B6B6B6",
			"#676767","#6767FF","#67FF67","#67FFFF","#FF6767","#FF67FF","#FFFF67","#FFFFFF",);
		for($i = 0; $i < $_POST['pollOptions']; $i++)
		{
			$options[] = array("choice"=>$_POST['pollOption'.$i], "color"=>$_POST['pollColor'.$i]);
		}
		$totalVotes = count($options);
		foreach($options as $option)
		{
			if($option['color'] == "")
				$option['color'] = $defaultColors[($pops + 9) % 16];
			
			$votes = 1;

			$cellClass = ($cellClass+1) % 2;
			$label = format("{1}", $pc[$pops], $option['choice']);

			$bar = "";
			if($totalVotes > 0)
			{
				$width = 100 * ($votes / $totalVotes);
				$alt = format("{0}&nbsp;of&nbsp;{1},&nbsp;{2}%", $votes, $totalVotes, $width);
				$bar = format("<div class=\"pollbar\" style=\"background: {0}; width: {1}%;\" title=\"{2}\">&nbsp;{3}</div>", $option['color'], $width, $alt, $votes);
				if($width == 0)
					$bar = "&nbsp;".$votes;
			}			

			$pollLines .= format(
"
	<tr class=\"cell{0}\">
		<td>
			{1}
		</td>
		<td class=\"width75\">
			<div class=\"pollbarContainer\">
				{2}
			</div>
		</td>
	</tr>
", $cellClass, $label, $bar);
			$pops++;
		}
		write(
"
	<table class=\"outline margin\">
		<tr class=\"header0\">
			<th colspan=\"2\">
				".__("Poll")."
			</th>
		</tr>
		<tr class=\"cell0\">
			<td colspan=\"2\">
				{1}
			</td>
		</tr>
		{2}
	</table>
", $cellClass, $_POST['pollQuestion'], $pollLines);
	}

	$previewPost['text'] = $_POST["text"];
	$previewPost['num'] = $loguser['posts']+1;
	$previewPost['posts'] = $loguser['posts']+1;
	$previewPost['id'] = "???";
	$previewPost['options'] = 0;<commit_msg>Added htmlentities to poll preview.<commit_after><?php
//  AcmlmBoard XD - Thread submission/preview page
//  Access: users

$title = __("New thread");

AssertForbidden("makeThread");

if(!$loguserid) //Not logged in?
	Kill(__("You must be logged in to post."));

if(isset($_POST['id']))
	$_GET['id'] = $_POST['id'];

if(!isset($_GET['id']))
	Kill(__("Forum ID unspecified."));

$fid = (int)$_GET['id'];

if($loguser['powerlevel'] < 0)
	Kill(__("You're banned."));

$rFora = Query("select * from {forums} where id={0}", $fid);
if(NumRows($rFora))
	$forum = Fetch($rFora);
else
	Kill(__("Unknown forum ID."));

if($forum['locked'])
	Kill(__("This forum is locked."));

if($forum['minpowerthread'] > $loguser['powerlevel'])
	Kill(__("You are not allowed to post threads in this forum."));

if(!isset($_POST['poll']) || isset($_GET['poll']))
	$_POST['poll'] = $_GET['poll'];


$OnlineUsersFid = $fid;

MakeCrumbs(array($forum['title']=>actionLink("forum", $fid), __("New thread")=>""), $links);

if(isset($_POST['actionpreview']))
{
	if($_POST['poll'])
	{
		$options = array();
		$noColors = 0;
		$defaultColors = array(
			"#000000","#0000B6","#00B600","#00B6B6","#B60000","#B600B6","#B66700","#B6B6B6",
			"#676767","#6767FF","#67FF67","#67FFFF","#FF6767","#FF67FF","#FFFF67","#FFFFFF",);
		for($i = 0; $i < $_POST['pollOptions']; $i++)
		{
			$options[] = array("choice"=>$_POST['pollOption'.$i], "color"=>$_POST['pollColor'.$i]);
		}
		$totalVotes = count($options);
		foreach($options as $option)
		{
			if($option['color'] == "")
				$option['color'] = $defaultColors[($pops + 9) % 16];
			
			$votes = 1;

			$cellClass = ($cellClass+1) % 2;
			$label = format("{1}", $pc[$pops], htmlspecialchars($option['choice']));

			$bar = "";
			if($totalVotes > 0)
			{
				$width = 100 * ($votes / $totalVotes);
				$alt = format("{0}&nbsp;of&nbsp;{1},&nbsp;{2}%", $votes, $totalVotes, $width);
				$bar = format("<div class=\"pollbar\" style=\"background: {0}; width: {1}%;\" title=\"{2}\">&nbsp;{3}</div>", $option['color'], $width, $alt, $votes);
				if($width == 0)
					$bar = "&nbsp;".$votes;
			}			

			$pollLines .= format(
"
	<tr class=\"cell{0}\">
		<td>
			{1}
		</td>
		<td class=\"width75\">
			<div class=\"pollbarContainer\">
				{2}
			</div>
		</td>
	</tr>
", $cellClass, $label, $bar);
			$pops++;
		}
		write(
"
	<table class=\"outline margin\">
		<tr class=\"header0\">
			<th colspan=\"2\">
				".__("Poll")."
			</th>
		</tr>
		<tr class=\"cell0\">
			<td colspan=\"2\">
				{1}
			</td>
		</tr>
		{2}
	</table>
", $cellClass, htmlspecialchars($_POST['pollQuestion']), $pollLines);
	}

	$previewPost['text'] = $_POST["text"];
	$previewPost['num'] = $loguser['posts']+1;
	$previewPost['posts'] = $loguser['posts']+1;
	$previewPost['id'] = "???";
	$previewPost['options'] = 0;
{'fraction_non_alphanumeric': 0.27586830680173663, 'fraction_numerical': 0.03545586107091172, 'mean_word_length': 4.584848484848485, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 55, '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': '875777', 'n_tokens_mistral': 2490, 'n_tokens_neox': 2193, 'n_words': 391}