<commit_before><?php

	// Copyright (C) 2014 <NAME>
	//
	//	This program is free software: you can redistribute it and/or modify
	//	it under the terms of the GNU Affero General Public License as
	//	published by the Free Software Foundation, either version 3 of the
	//	License, or (at your option) any later version.
	//
	//	This program is distributed in the hope that it will be useful,
	//	but WITHOUT ANY WARRANTY; without even the implied warranty of
	//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	//	GNU Affero General Public License for more details.
	//
	//	You should have received a copy of the GNU Affero General Public License
	//	along with this program.  If not, see <http://www.gnu.org/licenses/>.


	// Display source code
	if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
		if (isset($_GET['source'])) {
			header('Content-type: text/plain; charset=UTF-8');
			exit(file_get_contents(basename(__FILE__)));
		}
	}

	$php_title = $this->setup->text['post_cmt_on'][0];

	if ($this->setup->display_title == 'yes') {
		$php_title .= str_replace('_TITLE_', $this->setup->page_title, $this->setup->text['post_cmt_on'][1]);
	}

	class PhpMode
	{
		public $notifications,
		       $template_replace,
		       $form_avatar,
		       $form_first_image,
		       $is_a_reply = false,
		       $is_an_edit = false;

		// Default form settings
		public $name_on		= true,
		       $password_on	= true,
		       $email_on	= true,
		       $website_on	= true;

		public function __construct($read_comments, $setup)
		{
			$this->read_comments = $read_comments;
			$this->setup = $setup;

			// Avatar icon for edit and reply forms
			if (!empty($_COOKIE['name']) and preg_match('/^@([a-zA-Z0-9_@]{1,29}$)/', $_COOKIE['name'])) {
				$this->form_avatar = '<img width="' . $this->setup->icon_size . '" height="' . $this->setup->icon_size . '" src="' . $this->setup->root_dir . '/scripts/avatars.php?format=' . $this->setup->image_format . '&amp;size=' . $this->setup->icon_size . '&amp;username=' . $_COOKIE['name'] . '&amp;email=' . md5(strtolower(trim($_COOKIE['email']))) . '" alt="#' . $this->read_comments->cmt_count . '">';
			} else {
				$this->form_avatar = '<img width="' . $this->setup->icon_size . '" height="' . $this->setup->icon_size . '" src="' . $this->setup->root_dir . '/scripts/avatars.php?format=' . $this->setup->image_format . '&amp;size=' . $this->setup->icon_size . ((isset($_COOKIE['email'])) ? '&amp;email=' . md5(strtolower(trim($_COOKIE['email']))) : '') . '" alt="#' . $this->read_comments->cmt_count . '">';
			}

			$this->form_first_image = '<img width="' . $this->setup->icon_size . '" height="' . $this->setup->icon_size . '" src="' . $this->setup->root_dir . '/images/' . $this->setup->image_format . 's/first-comment.' . $this->setup->image_format . '" alt="+">';

			// Load HTML template
			$layout_file = file_get_contents('./themes/' . $this->setup->theme . '/layout.html');
			$this->theme_layout = trim($layout_file);
		}

		public function parse_template(array $comment, $forPop = false)
		{
			$this->forPop = $forPop;

			$this->template_replace = array(
				'cmtclass' => '',
				'permalink' => str_replace('_pop', '', $comment['permalink'])
			);

			if ($forPop == false) {
				if (strpos($comment['permalink'], 'r') !== false) {
					$this->template_replace['cmtclass'] .= ' hashover-reply';
				}
			}

			// Check if either a reply or edit is happening
			$this->is_a_reply = in_array('hashover_reply=' . $comment['permalink'], $this->setup->parse_url['query']);
			$this->is_an_edit = in_array('hashover_edit=' . $comment['permalink'], $this->setup->parse_url['query']);

			// Generate necessary indention for HTML output
			$indention = str_repeat("\t", substr_count($comment['permalink'], 'r'));

			if (isset($comment['notice_class'])) {
				$this->template_replace['cmtclass'] .= ' ' . $comment['notice_class'];
			}

			echo "\t", $indention, '<div id="', $comment['permalink'], '" class="hashover-comment', $this->template_replace['cmtclass'], '">', PHP_EOL;

			if ($this->setup->icon_mode != 'none') {
				if ($this->setup->icon_mode == 'image') {
					$php_avatar = '<img width="' . $this->setup->icon_size . '" height="' . $this->setup->icon_size . '" src="' . $comment['avatar'] .  '" alt="#' . $comment['permalink'] .  '">';
				} else {
					$avatar_link_text = explode('r', substr($comment['permalink'], 1));
					$php_avatar = '<a href="#' . $comment['permalink'] . '" title="Permalink">#' . array_pop($avatar_link_text) . '</a>';
				}
			}

			// Setup avatar icon
			if (isset($comment['avatar'])) {
				$this->template_replace['avatar'] = '<span class="hashover-avatar">' . $php_avatar . '</span>';
			}

			if (!isset($comment['notice'])) {
				if (!empty($comment['likes']) and $comment['likes'] > 0) {
					$likes_num = $comment['likes'] . ' ' . $this->setup->text['like'][($comment['likes'] != '1')];
				} else {
					$likes_num = '';
				}

				if (!empty($comment['dislikes']) and $comment['dislikes'] > 0) {
					$dislikes_num = $comment['dislikes'] . ' ' . $this->setup->text['dislike'][($comment['dislikes'] != '1')];
				} else {
					$dislikes_num = '';
				}

				$this->template_replace['name'] = $comment['name'];
				$this->template_replace['thread'] = (strpos($comment['permalink'], 'r') !== false) ? '<a href="#' . preg_replace('/^(.*)r.*$/', '\\1', $comment['permalink']) . '" title="' . $this->setup->text['thread_tip'] . '" class="hashover-thread-link">' . $this->setup->text['thread'] . '</a>' : '';
				$this->template_replace['comment'] = $comment['comment'];
				$this->template_replace['action'] = $_SERVER['PHP_SELF'];
				$this->template_replace['likes'] = '<span id="hashover-likes-' . $comment['permalink'] . '" class="hashover-likes">' . $likes_num . '</span>';
				$this->template_replace['dislikes'] = '<span id="hashover-dislikes-' . $comment['permalink'] . '" class="hashover-dislikes">' . $dislikes_num . '</span>';
				$this->template_replace['date'] = '<a href="#' . $comment['permalink'] .  '" title="Permalink">' . $comment['date'] .  '</a>';
				$this->template_replace['dislike_link'] = (!empty($comment['dislike_link'])) ? $comment['dislike_link'] : '';
				$this->template_replace['like_link'] = (!empty($comment['like_link'])) ? $comment['like_link'] : '';
				$this->template_replace['edit_link'] = (!empty($comment['edit_link'])) ? $comment['edit_link'] : '';
				$this->template_replace['reply_link'] = $comment['reply_link'];

				if ($forPop == false) {
					if ($this->is_an_edit) {
						$this->template_replace['hashover_footer_style'] = ' style="display: none;"';
					}<commit_msg>Added new `hashover-date-permalink` class<commit_after><?php

	// Copyright (C) 2014 <NAME>
	//
	//	This program is free software: you can redistribute it and/or modify
	//	it under the terms of the GNU Affero General Public License as
	//	published by the Free Software Foundation, either version 3 of the
	//	License, or (at your option) any later version.
	//
	//	This program is distributed in the hope that it will be useful,
	//	but WITHOUT ANY WARRANTY; without even the implied warranty of
	//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	//	GNU Affero General Public License for more details.
	//
	//	You should have received a copy of the GNU Affero General Public License
	//	along with this program.  If not, see <http://www.gnu.org/licenses/>.


	// Display source code
	if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
		if (isset($_GET['source'])) {
			header('Content-type: text/plain; charset=UTF-8');
			exit(file_get_contents(basename(__FILE__)));
		}
	}

	$php_title = $this->setup->text['post_cmt_on'][0];

	if ($this->setup->display_title == 'yes') {
		$php_title .= str_replace('_TITLE_', $this->setup->page_title, $this->setup->text['post_cmt_on'][1]);
	}

	class PhpMode
	{
		public $notifications,
		       $template_replace,
		       $form_avatar,
		       $form_first_image,
		       $is_a_reply = false,
		       $is_an_edit = false;

		// Default form settings
		public $name_on		= true,
		       $password_on	= true,
		       $email_on	= true,
		       $website_on	= true;

		public function __construct($read_comments, $setup)
		{
			$this->read_comments = $read_comments;
			$this->setup = $setup;

			// Avatar icon for edit and reply forms
			if (!empty($_COOKIE['name']) and preg_match('/^@([a-zA-Z0-9_@]{1,29}$)/', $_COOKIE['name'])) {
				$this->form_avatar = '<img width="' . $this->setup->icon_size . '" height="' . $this->setup->icon_size . '" src="' . $this->setup->root_dir . '/scripts/avatars.php?format=' . $this->setup->image_format . '&amp;size=' . $this->setup->icon_size . '&amp;username=' . $_COOKIE['name'] . '&amp;email=' . md5(strtolower(trim($_COOKIE['email']))) . '" alt="#' . $this->read_comments->cmt_count . '">';
			} else {
				$this->form_avatar = '<img width="' . $this->setup->icon_size . '" height="' . $this->setup->icon_size . '" src="' . $this->setup->root_dir . '/scripts/avatars.php?format=' . $this->setup->image_format . '&amp;size=' . $this->setup->icon_size . ((isset($_COOKIE['email'])) ? '&amp;email=' . md5(strtolower(trim($_COOKIE['email']))) : '') . '" alt="#' . $this->read_comments->cmt_count . '">';
			}

			$this->form_first_image = '<img width="' . $this->setup->icon_size . '" height="' . $this->setup->icon_size . '" src="' . $this->setup->root_dir . '/images/' . $this->setup->image_format . 's/first-comment.' . $this->setup->image_format . '" alt="+">';

			// Load HTML template
			$layout_file = file_get_contents('./themes/' . $this->setup->theme . '/layout.html');
			$this->theme_layout = trim($layout_file);
		}

		public function parse_template(array $comment, $forPop = false)
		{
			$this->forPop = $forPop;

			$this->template_replace = array(
				'cmtclass' => '',
				'permalink' => str_replace('_pop', '', $comment['permalink'])
			);

			if ($forPop == false) {
				if (strpos($comment['permalink'], 'r') !== false) {
					$this->template_replace['cmtclass'] .= ' hashover-reply';
				}
			}

			// Check if either a reply or edit is happening
			$this->is_a_reply = in_array('hashover_reply=' . $comment['permalink'], $this->setup->parse_url['query']);
			$this->is_an_edit = in_array('hashover_edit=' . $comment['permalink'], $this->setup->parse_url['query']);

			// Generate necessary indention for HTML output
			$indention = str_repeat("\t", substr_count($comment['permalink'], 'r'));

			if (isset($comment['notice_class'])) {
				$this->template_replace['cmtclass'] .= ' ' . $comment['notice_class'];
			}

			echo "\t", $indention, '<div id="', $comment['permalink'], '" class="hashover-comment', $this->template_replace['cmtclass'], '">', PHP_EOL;

			if ($this->setup->icon_mode != 'none') {
				if ($this->setup->icon_mode == 'image') {
					$php_avatar = '<img width="' . $this->setup->icon_size . '" height="' . $this->setup->icon_size . '" src="' . $comment['avatar'] .  '" alt="#' . $comment['permalink'] .  '">';
				} else {
					$avatar_link_text = explode('r', substr($comment['permalink'], 1));
					$php_avatar = '<a href="#' . $comment['permalink'] . '" title="Permalink">#' . array_pop($avatar_link_text) . '</a>';
				}
			}

			// Setup avatar icon
			if (isset($comment['avatar'])) {
				$this->template_replace['avatar'] = '<span class="hashover-avatar">' . $php_avatar . '</span>';
			}

			if (!isset($comment['notice'])) {
				if (!empty($comment['likes']) and $comment['likes'] > 0) {
					$likes_num = $comment['likes'] . ' ' . $this->setup->text['like'][($comment['likes'] != '1')];
				} else {
					$likes_num = '';
				}

				if (!empty($comment['dislikes']) and $comment['dislikes'] > 0) {
					$dislikes_num = $comment['dislikes'] . ' ' . $this->setup->text['dislike'][($comment['dislikes'] != '1')];
				} else {
					$dislikes_num = '';
				}

				$this->template_replace['name'] = $comment['name'];
				$this->template_replace['thread'] = (strpos($comment['permalink'], 'r') !== false) ? '<a href="#' . preg_replace('/^(.*)r.*$/', '\\1', $comment['permalink']) . '" title="' . $this->setup->text['thread_tip'] . '" class="hashover-thread-link">' . $this->setup->text['thread'] . '</a>' : '';
				$this->template_replace['comment'] = $comment['comment'];
				$this->template_replace['action'] = $_SERVER['PHP_SELF'];
				$this->template_replace['likes'] = '<span id="hashover-likes-' . $comment['permalink'] . '" class="hashover-likes">' . $likes_num . '</span>';
				$this->template_replace['dislikes'] = '<span id="hashover-dislikes-' . $comment['permalink'] . '" class="hashover-dislikes">' . $dislikes_num . '</span>';
				$this->template_replace['date'] = '<a href="#' . $comment['permalink'] .  '" class="hashover-date-permalink" title="Permalink">' . $comment['date'] .  '</a>';
				$this->template_replace['dislike_link'] = (!empty($comment['dislike_link'])) ? $comment['dislike_link'] : '';
				$this->template_replace['like_link'] = (!empty($comment['like_link'])) ? $comment['like_link'] : '';
				$this->template_replace['edit_link'] = (!empty($comment['edit_link'])) ? $comment['edit_link'] : '';
				$this->template_replace['reply_link'] = $comment['reply_link'];

				if ($forPop == false) {
					if ($this->is_an_edit) {
						$this->template_replace['hashover_footer_style'] = ' style="display: none;"';
					}
{'fraction_non_alphanumeric': 0.2252623688155922, 'fraction_numerical': 0.0031484257871064467, 'mean_word_length': 3.9138121546961324, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 231, 'https://': 0, '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': '2619634', 'n_tokens_mistral': 5068, 'n_tokens_neox': 4512, 'n_words': 832}