<commit_before><?php
/*
	Admin Controller
	By <NAME>

	This file is part of Florrie.

	Florrie 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.

	Florrie 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 Florrie.  If not, see <http://www.gnu.org/licenses/>.
*/



require_once $_SERVER['DOCUMENT_ROOT'].'/florrie/controller/admin.php';


class Install extends Admin {

	public function __construct() {

		//----------------------------------------
		// Set up the templating system
		//----------------------------------------

		// Include & initialize the Twig templating library
		require_once $_SERVER['DOCUMENT_ROOT'].'/florrie/lib/twig/lib/Twig/Autoloader.php';
		Twig_Autoloader::register();

		// Use the system-level template directory
		$this->templateDir = $_SERVER['DOCUMENT_ROOT'].'/florrie/templates/';
	}


	// Route the various steps of the installation
	public function index() {

		// Check for a previous install
		if(!(empty($this->config) || empty($this->config['florrie']))) {

			$e = 'The install page cannot be accessed if 
				Florrie has already been installed';

			throw new ServerError($e);
		}

		// Check for requirements: if any of these fail, Florrie cannot be 
		//  installed until they are resolved.
		$missingRequirements = $missingRecommends = array();

		// SHA512 used for hashing passwords securely
		if(empty(CRYPT_SHA512)) {

			$missingRequirements[] = <<<SHA
Your system does not support SHA512 hashing; this prevents Florrie from
securely handling passwords. Upgrading to PHP 5.3 or newer will fix this.
SHA;
		}

		// Use OpenSSL functions to generate salt
		if(!function_exists('openssl_random_pseudo_bytes')) {

			$missingRecommends[] = <<<OPENSSL
We recommend OpenSSL for much more secure pseudo random number generation.
Your numbers will still be random-ish without it, but not what they could be!
OPENSSL;
		}

		if(!$this->filesWriteable) {
<commit_msg>Add Requirement Check For ripemd320 Hash (CSRF Tokens)<commit_after><?php
/*
	Admin Controller
	By <NAME>

	This file is part of Florrie.

	Florrie 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.

	Florrie 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 Florrie.  If not, see <http://www.gnu.org/licenses/>.
*/



require_once $_SERVER['DOCUMENT_ROOT'].'/florrie/controller/admin.php';


class Install extends Admin {

	public function __construct() {

		//----------------------------------------
		// Set up the templating system
		//----------------------------------------

		// Include & initialize the Twig templating library
		require_once $_SERVER['DOCUMENT_ROOT'].'/florrie/lib/twig/lib/Twig/Autoloader.php';
		Twig_Autoloader::register();

		// Use the system-level template directory
		$this->templateDir = $_SERVER['DOCUMENT_ROOT'].'/florrie/templates/';
	}


	// Route the various steps of the installation
	public function index() {

		// Check for a previous install
		if(!(empty($this->config) || empty($this->config['florrie']))) {

			$e = 'The install page cannot be accessed if 
				Florrie has already been installed';

			throw new ServerError($e);
		}

		// Check for requirements: if any of these fail, Florrie cannot be 
		//  installed until they are resolved.
		$missingRequirements = $missingRecommends = array();

		// SHA512 used for hashing passwords securely
		if(empty(CRYPT_SHA512)) {

			$missingRequirements[] = <<<SHA
Your system does not support SHA512 hashing; this prevents Florrie from
securely handling passwords. Upgrading to PHP 5.3 or newer will fix this.
SHA;
		}

		// RIPE used for CSRF
		if(!(function_exists('hash_algos') && in_array('ripemd320', hash_algos()))) {
			$missingRequirements[] = <<<RIPE
Your system does not support ripemd320 hashing; this prevents Florrie from
generating CSRF tokens. However, IT DOESN'T HAVE TO BE THIS WAY! If you
encounter this error, file a bug and we can fix it with little effort. Yay!
RIPE;
		}

		// Use OpenSSL functions to generate salt
		if(!function_exists('openssl_random_pseudo_bytes')) {

			$missingRecommends[] = <<<OPENSSL
We recommend OpenSSL for much more secure pseudo random number generation.
Your numbers will still be random-ish without it, but not what they could be!
OPENSSL;
		}

		if(!$this->filesWriteable) {

{'fraction_non_alphanumeric': 0.1185617103984451, 'fraction_numerical': 0.00641399416909621, 'mean_word_length': 3.4362068965517243, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 15, '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': '1758786', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1409, 'n_words': 582}