<commit_before><?php
// wcf imports
require_once(WCF_DIR.'lib/page/AbstractPage.class.php');

/**
 * Default start page, displays all relevant informations.
 *
 * @author	<NAME>
 * @copyright	2009-2010 WoltLab Community
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.community.pb
 * @subpackage	page
 * @category 	PackageBuilder
 */
class IndexPage extends AbstractPage {
	public $templateName = 'index';

	// data
	public $sources = array();

	/**
	 * @see	Page::readData()
	 */
	public function readData() {
		$sql = "SELECT *
				FROM	pb".PB_N."_sources";
		$result = WCF::getDB()->sendQuery($sql);

		while ($row = WCF::getDB()->fetchArray($result)) {
			// fetch available revision if subversion is used
			if ($row['useSubversion']) {
				require_once(WCF_DIR.'lib/system/subversion/Subversion.class.php');
				$availableRevision = Subversion::getHeadRevision($row['url'], $row['username'], $row['password']);
				$row['availableRevision'] = $availableRevision;
			}

			$this->sources[] = $row;
		}
	}

	/**
	 * @see Page::assignVariables()
	 */
	public function assignVariables() {
		parent::assignVariables();

		WCF::getTPL()->assign(array(
				'allowSpidersToIndexThisPage' => false,
				'sources' => $this->sources
		));
	}

	/**
	 * @see	Page::show()
	 */
	public function show() {
		// validate general permission
		if (!WCF::getUser()->getPermission('user.source.general.canViewSources')) throw new PermissionDeniedException();

		parent::show();
	}
}
?><commit_msg>Permission check with $neededPermissions instead of modifying the show method<commit_after><?php
// wcf imports
require_once(WCF_DIR.'lib/page/AbstractPage.class.php');

/**
 * Default start page, displays all relevant informations.
 *
 * @author	<NAME>
 * @copyright	2009-2010 WoltLab Community
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.community.pb
 * @subpackage	page
 * @category 	PackageBuilder
 */
class IndexPage extends AbstractPage {
	public $templateName = 'index';
	public $neededPermissions = 'user.source.general.canViewSources';
	// data
	public $sources = array();

	/**
	 * @see	Page::readData()
	 */
	public function readData() {
		$sql = "SELECT *
				FROM	pb".PB_N."_sources";
		$result = WCF::getDB()->sendQuery($sql);

		while ($row = WCF::getDB()->fetchArray($result)) {
			// fetch available revision if subversion is used
			if ($row['useSubversion']) {
				require_once(WCF_DIR.'lib/system/subversion/Subversion.class.php');
				$availableRevision = Subversion::getHeadRevision($row['url'], $row['username'], $row['password']);
				$row['availableRevision'] = $availableRevision;
			}

			$this->sources[] = $row;
		}
	}

	/**
	 * @see Page::assignVariables()
	 */
	public function assignVariables() {
		parent::assignVariables();

		WCF::getTPL()->assign(array(
				'allowSpidersToIndexThisPage' => false,
				'sources' => $this->sources
		));
	}
}
?>
{'fraction_non_alphanumeric': 0.1674975074775673, 'fraction_numerical': 0.005317381189764041, 'mean_word_length': 4.355871886120997, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, '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': '257878', 'n_tokens_mistral': 1058, 'n_tokens_neox': 941, 'n_words': 194}